Is your feature request related to a problem? Please describe.
Have seen this used in quite a few projects. We could neaten that by providing it centrally in a way linked to the data screener.
Describe the solution you'd like
A function that pulls from the EES data screener repo to get the potential time and location cols, then replaces NAs with 'z', the GSS symbol for not available.
# Replace NAs with zs in the right places------------------------
z_replace <- function(table_name) {
table_name %>% # take name of table you want
mutate_at(vars(-region_code, -region_name, -old_la_code, -new_la_code, -la_name), ~ replace_na(., "z")) # replace all NAs apart from geographic data with "z"
}
Describe alternatives you've considered
Could expand this a little to take in more inputs, and also replace specific values. 'x' would be suitable for not available for example.
Would be worth doing a quick speed test against a data.table equivalent, as we're putting into a function we can care less about readability behind the scenes and more about speed (especially as this could be applied to some large datasets!).
Is your feature request related to a problem? Please describe.
Have seen this used in quite a few projects. We could neaten that by providing it centrally in a way linked to the data screener.
Describe the solution you'd like
A function that pulls from the EES data screener repo to get the potential time and location cols, then replaces NAs with 'z', the GSS symbol for not available.
Describe alternatives you've considered
Could expand this a little to take in more inputs, and also replace specific values. 'x' would be suitable for not available for example.
Would be worth doing a quick speed test against a data.table equivalent, as we're putting into a function we can care less about readability behind the scenes and more about speed (especially as this could be applied to some large datasets!).
Additional context
None.