【发布时间】:2019-11-13 17:19:34
【问题描述】:
我试图总结我的数据集中的所有列(它有很多列,尽管下面的代表示例只有 2 个),得到每个变量的均值和 sd。我希望输出为长格式。
#Example dataset
d <- iris %>% select(Sepal.Length,Sepal.Width)
names(d) <- c("SepalLength","SepalWidth")
#Summarizing and trying to make it long
s <- d %>% summarize_each( list(mean=mean,sd=sd) ) # has summar stats, but they are in wide format
# trying to pivot.
s %>% pivot_longer( ??? what do I put here ???)
我尝试了一些变体(例如:pivot_longer(names_to = "key", values_to = "value")),但总是收到错误消息。
【问题讨论】: