atorus-research / xportr

Tools to build CDISC compliant data sets and check for CDISC compliance.
https://atorus-research.github.io/xportr/
Other
39 stars 8 forks source link

Feature Request: Add "hms" to xportr.numeric_types #271

Open bundfussr opened 5 days ago

bundfussr commented 5 days ago

Feature Idea

I would suggest to add "hms" to the default value of xportr.numeric_types. Time variables which are created by admiral::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

library(xportr)
library(magrittr)
library(admiral)
metadata <- data.frame(
  dataset = "test",
  variable = c("ADTM", "ATM"),
  type = "numeric"
)

.df <- data.frame(
  ADTM = convert_dtc_to_dtm("2024-03-24T12:34:56")
) %>% derive_vars_dtm_to_tm(source_vars = exprs(ADTM))

df2 <- xportr_type(.df, metadata, "test", verbose = "warn")

produces


── Variable type mismatches found. ──

✔ 1 variables coerced
Warning message:
Variable type(s) in dataframe don't match metadata: `ATM`
bundfussr commented 5 days ago

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.

bms63 commented 2 days ago

@atorus-research/xportr-development-team anyone on the team want to make this update?