I had some working code. I had to update R (and install all packages again) and when I try to run the code again hit a wall. Here's a toy example:
WORKING CODE
# get cyl column
mtcars %>% dplyr::select(cyl)
# add 1 to all numeric
mtcars %>% dplyr::mutate_if(is.numeric, ~.+1)
WALL
But when I try to divide all numeric columns for the cyl
column I can't.
mtcars %>% mutate_if(is.numeric, ~./cyl)
Error in mutate_impl(.data, dots) :
Evaluation error: object 'cyl' not found.
By the way...this works
mtcars %>% mutate_if(is.numeric, ~./mtcars$cyl)
For some reason mutate_if
is not finding the column (although select
does).
map_if
from purrr
package has the same behavior.