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

export() to *.xlsx with fill=NA? #198

Closed
modche opened this Issue Feb 1, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@modche
Copy link

modche commented Feb 1, 2019

  • [ x] a suggested code or documentation change, improvement to the code, or feature request

Hi,

rio-package is really nice!

Is there a way to export a tibbleto *.xlsxwith filled NA-values for empty cells in the data_frame?

Michael

@leeper leeper added the question label Feb 1, 2019

@leeper

This comment has been minimized.

Copy link
Owner

leeper commented Feb 1, 2019

I'm not sure actually. I'll investigate. If you find a good solution, please consider a PR!

@nathancday

This comment has been minimized.

Copy link
Contributor

nathancday commented Feb 9, 2019

If the columns are empty strings, "", looks like you would need to convert them to proper NA values firsts, perhaps with dplyr::na_if(). But once they are official R NAs you can pass the argument keepNA = TRUE to get NA representations written to Excel.

mtcars[1,] <- NA
mtcars %>% export("tst.xlsx")
mtcars %>% export("tst2.xlsx", keepNA = TRUE)
# see ?openxlsx::write.xlsx for more available arguments
@leeper

This comment has been minimized.

Copy link
Owner

leeper commented Feb 26, 2019

I've added this as an example to ? export, which seems sufficient at this point. Thanks, @nathancday!

@leeper leeper closed this in e0c8727 Feb 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment