我有一个包含700k行和6k个事实的数据框,其结构类似于此:
test1 = data.frame("date" = c("2018/11", "2018/10", "2018/11", "2018/10"), "season" = c("s01", "s02", "s01", "s02"), "product" =
c("p01", "p01", "p02", "p02"), "qty" = c(110, 55, 80, 15))
(更新:我更正了代码以描述结果) 我需要将出现在行中的每个因素都放在一列中,像这样:
test3 = data.frame("date" = c("2018/10", "2018/11"), "season" = c("s02", "s01"), "p01" =
c(55, 110), "p02" = c(15, 80))
我当时使用dplyr
来过滤一些因素,但是在这种情况下,我不知道该怎么做。