Closed mianzg closed 2 months ago
@larnsce factor is a special case of integer data type in R, so typeof()
will return factor variables as integer too. However,class()
will not differentiate detailed numeric type, for instance, it will return "numeric" for both "integer" and "double".
What do you think? Or we can add an if-else statement just for factor type.
I think it's alright to show class numeric for integer or double. It's more meaningful to people that would look at the README anyways.
Changed it to use class()
date types will cause an error in var_type <- c(var_type, sapply(tidydata, class))
what happened: class(date object)
returns [1] "POSIXct" "POSIXt"
, therefore, var_type
will be a nested list instead of a vector.
expected: var_type
should be the same length as file_name
and var_name
to make a final data frame to output
solution: coerce var_type
to be a character vector
https://github.com/openwashdata-dev/washr/blob/6c3d61ccfcf69880e86dda40cebf1d32b60c959a/R/setup_dictionary.R#L99C5-L99C54
Instead of using
typeof()
, consider to change intoclass()