Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

dplyr mutate_if with multiple conditions?

$
0
0

I have data that looks as the following:

dt <- data.frame(id = sample(LETTERS, 100) ,A = seq(1:100), B = sample(1:100000, 100), C = rpois(100,1), D = seq(1:100)^3)

I am trying to transform any variable that has a max value > 1000

dt %>% mutate_if(max(.) > 1000, log10)

For model fitting. But I keep getting the following error:

Error in tbl_if_vars(.tbl, .p, .env, ..., .include_group_vars = .include_group_vars) : 
  length(.p) == length(tibble_vars) is not TRUE

Please help!


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>