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

'xl_formula' fails when there are any NAs in otherwise valid vector #40

Closed
mir-cat opened this issue Sep 20, 2019 · 0 comments
Closed

Comments

@mir-cat
Copy link

mir-cat commented Sep 20, 2019

xl_formula checks that all values in the vector start with an '=' to ensure that every value is a valid formula. However, if there are any NAs in the vector, even if every non na value starts with '=', the function call fails. Manually setting the class of a column to "c('xl_formula', 'xl_object)" has the behavior that all NAs are blank in the excel output, which to me seems to be the desired behavior.

I think this could be fixed by adding 'na.rm = T' to the 'all' call that checks for '=' at the start of every value.

reprex below:

formula <- paste0('=A', seq_len(5))

writexl::xl_formula(formula)
#>  [:xl_formula:]
#> =A1
#> =A2
#> =A3
#> =A4
#> =A5

formula[1] <- NA

writexl::xl_formula(formula)
#> Error in writexl::xl_formula(formula): Formulas must start with '='
@jeroen jeroen closed this as completed in 1e6d688 Nov 27, 2019
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

1 participant