This is my data:
dat <- mtcars
dat$Brands <- rownames(dat)
dat$Info <- rep("Info", length(rownames(mtcars)))
I have seen that there are a lot of ways to do something into an entire data frame. mutate
, sapply
, etc. However, for some particular functions it doesn't work.
The closest example is if you want to do log2+1
.
I have tried this...
data_log <- dat %>% mutate(across(where(is.numeric), log2+1))
But it gives me this error...
Error: Problem with
mutate()
input..1
. ℹ..1 = across(where(is.numeric), log2 + 1)
. x non-numeric argument to binary operator Runrlang::last_error()
to see where the error occurred.
Do you know if there is a way to run this type of function?