Open sebdalgarno opened 6 years ago
remove units with ability to guess integer/numeric:
is.units <- function(x) inherits(x, 'units')
to_numeric <- function(x) {
if(all(x == floor(x), na.rm = T))
return(as.integer(x))
as.numeric(x)
}
ps_strip_units <- function(x) modify_if(x, is.units, to_numeric)
let me know if you have any suggestions
there is a simpler method that works - as.vector:
is.units <- function(x) inherits(x, 'units')
ps_strip_units <- function(x) modify_if(x, is.units, as.vector)
yes this last solution seems very elegant
three common operations at the top of clean/tidy-data scripts are/could be:
ideally these would be done by using
ps_env_map_df()
at the moment,ps_env_map_df(ps_deactivate_sfc())
is possible I thinkps_env_map_df(ps_deactivate_units())
andps_env_map_df(ps_remove_blobs())
would be useful enough to have their own functions.