【发布时间】:2020-12-10 14:10:01
【问题描述】:
考虑到这个小标题
library(tibble)
mytab <- tribble(
~siren_ent, ~nbeta_dep01, ~nbeta_dep02, ~effeta_dep01, ~effeta_dep02, ~categ,
"A", 3, 0, 50, 0, "X",
"B", 0, 2, 0, 30, "X",
"C", 1, 1, 10, 15, "Y"
)
我想旋转它以获得这个结果...
> result
# A tibble: 4 x 4
DEP categ nbeta effeta
<chr> <chr> <dbl> <dbl>
1 01 X 3 50
2 01 X 1 10
3 02 Y 2 30
4 02 Y 1 15
如果你有 tidyverse 的解决方案,我很感兴趣。
提前非常感谢!
【问题讨论】:
-
有两列叫
effeta_dep01,我假设一列应该是effeta_dep02? -
是的,抱歉,我编辑了