【发布时间】:2021-08-11 13:16:03
【问题描述】:
这是我的数据:
dat <- mtcars
dat$Brands <- rownames(dat)
dat$Info <- rep("Info", length(rownames(mtcars)))
我已经看到有很多方法可以对整个数据框执行某些操作。 mutate、sapply 等。但是,对于某些特定功能,它不起作用。
最接近的例子是如果你想做log2+1。
这个我试过了……
data_log <- dat %>% mutate(across(where(is.numeric), log2+1))
但它给了我这个错误......
错误:
mutate()输入..1有问题。 ℹ..1 = across(where(is.numeric), log2 + 1)。 x 二元运算符的非数字参数 运行rlang::last_error()看看哪里出错了。
你知道有没有办法运行这种类型的函数?
【问题讨论】:
标签: r dataframe dplyr logarithm