-
Notifications
You must be signed in to change notification settings - Fork 9
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
Feature Request: Add "hms" to xportr.numeric_types #271
Comments
By the way, the message could be improved by stating which type was found in metadata and which in data. I had to read the code to find out what caused the warning. |
@atorus-research/xportr-development-team anyone on the team want to make this update? |
@bms63 , I wonder if the documentation of Also on the "Get started" page it says
But in the example no variable was coerced and there are still variables which are not numeric or character, e.g., dates. What do you think? |
So - I was using xport_type() a few weeks ago and could of sworn it used to coerce dates classes to numeric as this allows you to apply the format using xportr_format(), but something happened preventing me from doing this. But yes agree to updates. Just a bit confused on the behavior of this function and xportr_format(). Here I have an example where the formats were not applied nor the Date class coerced. https://github.com/pharmaverse/rpharma-2024-ADaM-workshop/blob/main/solutions/adsl.R @elimillera and @cpiraux any ideas? |
In the latest update of the xport_type function, the format specified in the specs is normally not considered when determining whether a variable should be coerced. Dates, datetimes, and times should, in theory, not be coerced to numeric; otherwise, the haven package will not recognize these variables correctly as date, datetime, or time, which could lead to incorrect date values in the XPT file. Here’s an explanation of how it works: For instance, a numeric date variable is categorized as numeric, and if the specs also categorize it as numeric, the R class remains unchanged (class(variable) = "Date"). I’ve drafted a figure to explain this. It might not be entirely clear yet, but it provides some logical structure. |
Lovely summary Celine appreciate it. So when a variable has a Date or Datetime class I can not associate the format with it. I would think the attributes could be associated with a Date class, but it looks like the current version of xportr_format can't do that. Maybe it is something to do with admiral functions. Can you take a look at the code that is available above please |
@bms63 , I think it is possible. I've just tried it with the admiralroche ADEX script. For example,
|
@bundfussr is the spec a metacore object that is applying the format using |
Yes |
I feel like there is something wrong with my code then - as I can only get the format to apply to I have used xportr_format() in the past with success but never used a metacore object until now. Wondering if there is just some weird variation in my spec that is causing the issue. |
@bms63 , I needed to update the
|
@bundfussr yay!!!!!! You are too amazing. @Fanny-Gautier check this out!! |
Well - still not working for me. @bundfussr what is your session info
|
@bms63 , my session info is:
However, I think it's just an issue in RStudio. When I look at the "Environment" tab in RStudio, I see the same as you. But when I print the attributes in the console it looks OK. |
Hi @bms63 , |
Closes #271 add_hms: add hms to xportr.numeric_types and add details to xpor…
Feature Idea
I would suggest to add
"hms"
to the default value ofxportr.numeric_types
. Time variables which are created byadmiral::derive_vars_dtm_to_tm()
are of class"hms"
. Without adding"hms"
xportr_type()
considers time variable as converted.Relevant Input
No response
Relevant Output
No response
Reproducible Example/Pseudo Code
produces
The text was updated successfully, but these errors were encountered: