在R中更改表列中的行结构

在R中更改表列中的行结构,r,datatable,rows,transpose,R,Datatable,Rows,Transpose,我有一张桌子,一开始看起来像这样: test <- data.frame("Season" = c("Winter", "Winter", "Winter", "Winter", "Winter", "Winter"), "Site" = c(123,123,123,123,123,123), "

我有一张桌子,一开始看起来像这样:

test <- data.frame("Season" = c("Winter", "Winter", "Winter", "Winter", "Winter", "Winter"),
       "Site" = c(123,123,123,123,123,123),
       "Flow" = c("H001", "H007", "H030", "L001", "L007", "L030"),
       "P-Value" = c(0.05, 0.05, 0.05, 0.05, 0.05, 0.05),
       "H0" = c(1, 1, 1, 1, 1, 1),
       "Stat" = c(0.4, 0.4, 0.4, 0.4, 0.4, 0.4),
       "Slope" = c(1, 1, 1, 1, 1, 1))
test_2 <- data.frame("Site" = c(123), "P-Value for H001 winter" = c(0.05), "P-Value for H007 winter" = c(0.05),
                 "P-Value for H030 winter" = c(0.05), "P-Value for L001 winter" = c(0.05), "P-Value for L007 winter" = c(0.05),
                 "P-Value for L030 winter" = c(0.05), "H0 for H001 winter" = c(1), "H0 for H007 winter" = c(1), "H0 for H030 winter" = c(1),
                 "H0 for L001 winter" = c(1), "H0 for L007 winter" = c(1), "H0 for L030 winter" = c(1),
                 "Stat for H001 winter" = c(0.04), "Stat for H007 winter" = c(0.04), "Stat for H030 winter" = c(0.04),
                 "Stat for L001 winter" = c(0.04), "Stat for L007 winter" = c(0.04), "Stat for L030 winter" = c(0.04),
                 "Slope for H001 winter" = c(1), "Slope for H007 winter" = c(1), "Slope for H030 winter" = c(1),
                 "Slope for L001 winter" = c(1), "Slope for L007 winter" = c(1), "Slope for L030 winter" = c(1))
test我想你想要这个:

测试%>%
枢轴长度(cols=c(P.值,H0,统计,斜率))%>%
变异(名称=粘贴(名称,“用于”,流量,季节))%>%
选择(-Flow,-Season)%>%
支点()
返回

结构(列表(现场=123,`H001冬季P.Value`=0.05,
`H001冬季的H0`=1,`H001冬季的Stat`=0.4,`H001冬季的坡度`=1,
`P.H007冬季`=0.05,`H0冬季`=1,
`H007冬季统计数据`=0.4,` H007冬季坡度`=1,
`P.H030冬季的值`=0.05,`H0冬季的值`=1,
`H030冬季的统计数据`=0.4,` H030冬季的坡度`=1,
`P.L001冬季的值`=0.05,`H0表示L001冬季`=1,
`L001冬季的统计数据`=0.4,` L001冬季的坡度`=1,
`P.L007冬季的值`=0.05,`H0表示L007冬季`=1,
`2007年冬季的统计数据`=0.4,` 2007年冬季的坡度`=1,
`P.L030冬季的值`=0.05,`H0对于L030冬季`=1,
`L030冬季的统计数据`=0.4,`L030冬季的斜率`=1),row.names=c(NA,
-1L),class=“data.frame”)

您想将表格分散在一行中吗?很乐意为您提供帮助。但我扪心自问:你为什么要把一个漂亮整洁的形体变成那个可憎的东西?