-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
0.3.0Issues to be worked on for release 0.3.0 (est. Jan 2026).Issues to be worked on for release 0.3.0 (est. Jan 2026).bugSomething isn't workingSomething isn't working
Description
When the codelist contains a negative number and is used to generate a new column using create_var_from_codelist the resulting column is cast to a character variable rather than a numeric. See example below:
library(metacore)
library(tibble)
library(metatools)
library(dplyr)
data <- tribble(
~USUBJID, ~VAR1, ~VAR2,
1, "M", "Male",
2, "F", "Female",
3, "F", "Female",
4, "U", "Unknown",
5, "M", "Male",
)
spec <- spec_to_metacore(metacore_example("p21_mock.xlsx"), quiet = TRUE)
dm_spec <- metacore(
ds_spec = spec$ds_spec,
ds_vars = spec$ds_vars,
var_spec = spec$var_spec,
value_spec = mutate(spec$value_spec, code_id = case_when(code_id != "SEX" ~ NA, TRUE ~ "SEX")),
derivations = spec$derivations,
supp = spec$supp,
codelist = structure(
list(
code_id = structure("SEX", label = "ID of the Code List"),
name = "SEX",
type = structure("code_decode", label = "Code List/Permitted Values/External Library"),
codes = structure(list(structure(list(code = c(-999, 2, 3), decode = c("Female", "Male", "Unknown")), row.names = c(NA, -3L), class = c("tbl_df", "tbl", "data.frame"))), label = "List of Codes")), row.names = c(NA, -1L), class = c("tbl_df", "tbl", "data.frame"))) %>%
select_dataset( "DM", quiet = TRUE)
create_var_from_codelist(data, dm_spec, VAR2, SEX)
Metadata
Metadata
Assignees
Labels
0.3.0Issues to be worked on for release 0.3.0 (est. Jan 2026).Issues to be worked on for release 0.3.0 (est. Jan 2026).bugSomething isn't workingSomething isn't working