Skip to content
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

Check use of NULL in metadata arguments #259

Open
bms63 opened this issue Mar 13, 2024 · 2 comments
Open

Check use of NULL in metadata arguments #259

bms63 opened this issue Mar 13, 2024 · 2 comments
Assignees

Comments

@bms63
Copy link
Collaborator

bms63 commented Mar 13, 2024

image

@EeethB
Copy link
Collaborator

EeethB commented Mar 13, 2024

Some more context from my own testing:

  • Example from xportr_metadata() runs fine without metadata:
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 if metadata is not set prior with xportr_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.

@bms63
Copy link
Collaborator Author

bms63 commented Mar 13, 2024

Thanks for taking a look!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants