Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor creation of required dataframes #8

Open
dave-mills opened this issue Apr 18, 2024 · 0 comments
Open

Refactor creation of required dataframes #8

dave-mills opened this issue Apr 18, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@dave-mills
Copy link
Member

Currently, many of the graphics functions require certain dataframes to already exist, particularly indicator_table, data_dictionary and code_lists.

One approach to this is to make getting these data their own functions, which can then be called in any context (at the start of a processing script; inside a function, where-ever). For example:

get_indicator_table <- function(con) {

    if(exists('indicator_table') && is.data.frame(get('indicator_table'))) {
        return indicator_table
     }

    return tbl(con, 'indicators') %>%
        collect()
}

Now, anywhere we need the indicator_table data, we can run indicator_table <- get_indicator_table(con). If the dataframe exists in the current environment / context, it will be used. Otherwise, we go out to the database to get it.

@dave-mills dave-mills added the enhancement New feature or request label Apr 18, 2024
alex-thomson222 pushed a commit that referenced this issue Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants