I know this issue is resolved already (thank you again for help) but what can I do if variables are integers (not numbers)?
Even if I change the code into:
mutate_if(~is.integer(.) && any(. > 0, na.rm = TRUE),
~ if_else(.x>0,1,.x))
I have following error:
Error: `false` must be a double vector, not an integer vector
Call `rlang::last_error()` to see a backtrace
>
Is recoding to num prior to this function a good solution?
library(dplyr)
source <- source %>% mutate_if(is.integer,as.numeric)
step1 <- source %>%
mutate_if(~is.numeric(.) && any(. > 0, na.rm = TRUE),
~ if_else(.x>0,1,.x))