【发布时间】:2020-08-07 10:05:54
【问题描述】:
我想将行转换为列以返回每种模式的平均成本。我正在尝试使用 pivot_wider 函数,但它给出了以下错误。
错误:此 tidyselect 接口尚不支持谓词。
i 联系包作者并建议使用eval_select()。
我尝试更新软件包,但问题仍然存在。除了 pivot_wider 之外,还有什么其他的方法可以得到想要的结果?
我的数据框prcostdata看起来像这样。
S447.1 cost
Car 100
Government Ambulance 50
Jeep 600
Scooter 800
Government Ambulance 100
Car 200
Jeep 1500
Scooter 750
期望的输出。
Government Ambulance Car Jeep Scooter
75 150 1050 775
这是我的代码。
library(dplyr)
library(tidyr)
trans <- c("Government Ambulance","Car","Jeep","Scooter")
prcostmode<-prcostdata %>%
arrange(match(S447.1, trans)) %>%
pivot_wider(names_from = S447.1, values_from = mean)
【问题讨论】: