Tidyverse: This tidyselect interface doesn't support predicates yet

巧了我就是萌 提交于 2021-02-11 08:01:52

问题


I am using R and exercising using the dslabs data for murders in the USA. As follows, library(dslabs) data("murders") library(tidyverse) murders <- mutate(murders, pop_in_millions = population / 10^6) murders <- mutate(murders, rate = total/population * 100000) murders <- mutate(murders, rank(-rate)) select(murders, state, rank) Error: This tidyselect interface doesn't support predicates yet. i Contact the package author and suggest using eval_select(). Run rlang::last_error() to see where the error occurred.


回答1:


In your last mutate call you forgot to create the rank variable. Therefore select can't find a column named rank in your dataset. The somewhat mysterious error message is related to the fact that R instead thinks you want to do something with the rank function. Try this:

library(dslabs) 
data("murders") 
library(tidyverse) 
murders <- mutate(murders, pop_in_millions = population / 10^6) 
murders <- mutate(murders, rate = total/population * 100000) 
murders <- mutate(murders, rank = rank(-rate)) 
head(select(murders, state, rank))
#>        state rank
#> 1    Alabama   23
#> 2     Alaska   27
#> 3    Arizona   10
#> 4   Arkansas   17
#> 5 California   14
#> 6   Colorado   38

Created on 2020-04-04 by the reprex package (v0.3.0)



来源:https://stackoverflow.com/questions/61022423/tidyverse-this-tidyselect-interface-doesnt-support-predicates-yet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!