【发布时间】:2022-01-11 03:38:02
【问题描述】:
我有一个像 aa 这样的数据集:
aa <- data_frame(month = c(1, 1, 2, 2),
type = c("most", "least", "most", "least"),
value = c(0.2, 0.8, 1, 0.1),
NP = c(4, 2, 0, 6),
NO = c(1, 5, 2, 4))
我想从长到宽 FOR ALL VARIABLES 但是(月份,类型)像 bb 这样的数据集包含更多列。
bb <- data_frame(month = c(1, 2),
value_most = c(0.2, 1),
value_least = c(0.8, 0.1),
NP_most = c(4, 0),
NP_least = c(2,6),
NO_most = c(1, 2),
NO_least = c(5, 4))
我试过 pivot_wider() 和 reshape() 都没有成功。
有什么线索吗?
【问题讨论】: