Check use of NULL in metadata arguments
bms63 opened this issue · comments
Some more context from my own testing:
- Example from
xportr_metadata()
runs fine withoutmetadata
:
metadata <- data.frame(
dataset = "test",
variable = c("Subj", "Param", "Val", "NotUsed"),
type = c("numeric", "character", "numeric", "character"),
format = NA,
order = c(1, 3, 4, 2)
)
adlb <- data.frame(
Subj = as.character(123, 456, 789),
Different = c("a", "b", "c"),
Val = c("1", "2", "3"),
Param = c("param1", "param2", "param3")
)
xportr_metadata(adlb, metadata, "test")
xportr_metadata(adlb, domain = "test") # metadata will be NULL
- Example from
xportr_type()
gives an error ifmetadata
is not set prior withxportr_metadata()
or explicitly in call to type:
metadata <- data.frame(
dataset = "test",
variable = c("Subj", "Param", "Val", "NotUsed"),
type = c("numeric", "character", "numeric", "character")
)
.df <- data.frame(
Subj = as.character(123, 456, 789),
Different = c("a", "b", "c"),
Val = c("1", "2", "3"),
Param = c("param1", "param2", "param3")
)
# These two work fine
xportr_type(.df, metadata, "test")
xportr_metadata(.df, metadata, "test") %>%
xportr_type()
# This tells you to set metadata somewhere, even though the `metadata` default is NULL
xportr_type(.df, domain = "test")
Given that the error is descriptive, and dropping the NULL default for metadata
would complicate some pipelines that xportr_metadata()
is meant to simplify, we're leaving this as is for now. It will be revisited in the next development push.
Thanks for taking a look!!