我目前正在使用pivot_longer
中的简单r函数。
这里是代码:
poll %>%
pivot_longer(poll, c(`Basketball`,`Football`), names_to="Sport", values_to="Percentage")
这些是用于查找篮球和足球百分比的代码。
这里是错误消息:
错误:必须对具有有效下标向量的列进行子集设置。
任何人都可以看看我的代码有什么问题吗?
poll %>%
pivot_longer(c("Basketball","Football"), names_to="Sport", values_to="Percentage")
OR
pivot_longer(poll, c("Basketball","Football"), names_to="Sport", values_to="Percentage")