Error in select(., cyl, mpg) : unused arguments (cyl, mpg)
问题:
#由于来自MASS包的select()函数与来自dplyr包的select()函数冲突,因此会发生错误。
library(dplyr)
library(MASS)
#find average mpg grouped by 'cyl'
mtcars %>%
select(cyl, mpg) %>%
group_by(cyl) %>%
summarise(avg_mpg = mean(mpg))
解决:
#指定使用那个包的select函数就好了
library(dplyr)
library(MASS)
#find average mpg grouped by 'cyl'
mtcars %>%
dplyr::select(cyl, mpg) %>%
group_by(cyl) %>%
summarise(avg_mpg = mean(mpg))
完整错误:
library(dplyr)
library(MASS)#find average mpg grouped by 'cyl'
mtcars %>%
select(cyl, mpg) %>%
group_by(cyl) %>%
Error in select(., cyl, mpg) : unused arguments (cyl, mpg)summarise(avg_mpg = mean(mpg))
版权归原作者 Data+Science+Insight 所有, 如有侵权,请联系我们删除。