Mutate_at() not ignoring NA values with janitor functions

dplyr
tidyverse

#1

After updating R to 3.5.1, my code:

IEU %>%
 mutate_at(vars(c(IEU_Submission_Date:IEU_Disbursed_Date)), excel_numeric_to_date)

could no longer function, with the error:

Error in mutate_impl(.data, dots) : 
  Evaluation error: missing value where TRUE/FALSE needed.

due to there being NA's present in 4 of the 5 columns. Previously, it was ignoring the NA values. Not sure if this is due to dplyr or the janitor excel_numeric_to_date() function. I would not like to remove these rows with NA values, but rather keep them as NA.

Thank you kindly for your support.


#2

Could you please turn this into a self-contained reprex (short for reproducible example)? It will help us help you if we can be sure we're all working with/looking at the same stuff.

install.reprex("reprex")

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page. The reprex dos and don'ts are also useful.

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "fruits_stringdist.md")

For pointers specific to the community site, check out the reprex FAQ, linked to below.


#3

This was a bug introduced in janitor v1.1.0, causing excel_numeric_to_date to fail in this way. The version that became available on CRAN today (v1.1.1) patches this bug and your code should run as before.


#4

Apologies, Tried to remove the question once I had your response Sam, couldn't figure out how to.

Thanks for the support all,

Corey


#5

Nothing wrong with letting it stand as a guidepost for anybody else who encounters the same thing (just because the bug is fixed now doesn’t mean people won’t still bump into it since not everybody keeps packages up to date).

Even more helpful: you can officially select @samfirke’s post as the solution (here’s how: FAQ: How do I mark a solution?).


#6

Ditto what @jcblum wrote. @Corey, I'm glad you filed this post and didn't remove it, I appreciate that it's a way for others with the same error to find a resolution. Thanks for reporting the bug!