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

missing value handling in avtable and avtable_import #75

Closed
smgogarten opened this issue Apr 7, 2023 · 2 comments
Closed

missing value handling in avtable and avtable_import #75

smgogarten opened this issue Apr 7, 2023 · 2 comments
Assignees

Comments

@smgogarten
Copy link

Currently, NA values in a data.frame written to AnVIL with avtable_import results in the string "NA" appearing in the AnVIL data table, regardless of data type. Reading the same data table back into R with avtable results in NA for numeric columns, but the character string "NA" for character columns.

It would be helpful to control how missing values are read and written, as in the na argument to read_delim and write_delim in the readr package.

@mtmorgan mtmorgan self-assigned this Apr 7, 2023
@mtmorgan
Copy link
Collaborator

mtmorgan commented Apr 7, 2023

Can you try

BiocManager::install("Bioconductor/AnVIL", ref = "issue-75-avtable-NA")

Examples include

## round-trip "" and NA_character_ from R to AnVIL and back
tbl0 <- tibble(
    issue75 = letters[1:4],
    x = c("a", "", NA, "d"),
    i = c(1:2, NA, 3L),
    r = as.numeric(i),
)
avtable_import(tbl0)
avtable("issue75", na = "NA")

## preserve "", NA_character_, and "NA" (sodium? North America?)
tbl0 <- tibble(
    issue75 = letters[1:4],
    x = c("a", "", NA, "NA"),
    i = c(1:2, NA, 3L),
    r = as.numeric(i),
)
avtable_import(tbl0, na = "__MISSING_VALUE__")
avtable("issue75", na = "__MISSING_VALUE__")

This follows the {readr} defaults, and change the default behavior of AnVIL (which wasn't very helpful anyway)

@smgogarten
Copy link
Author

This is great, thank you!

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