我有一个干净的tibble,如下所示:R:tibble移动列以行和名称列
df <- structure(list(created_week = c(31, 32, 33, 34), Rt_count = c(7,
6, 5, 0), Cus_count = c(2, 1, 2, 1)), class = c("tbl_df", "tbl",
"data.frame"), .Names = c("created_week", "Rt_count", "Cus_count"
), row.names = c(NA, -4L))
我在看做与从碱T(),具有tibble作为结果和行从df $ created_week和他们的名字,列是Rt_count和Cus_count,必须命名。 我找不到一个简单而简单的方法。
谢谢你的帮助。
我不知道我是否理解。如果Rt_count&Cus_count保留列,是否转置数据框?或者你只是想将第一列转换为行名?对于后者,请查看'tibble :: column_to_rownames' –
@ Z.Lin column_to_rownames(tt,var =“toto”) 错误:未找到列'num2' – gabx
您必须指定将哪一列转换为rowname。尝试'df%>%column_to_rownames(“created_week”)%>%as.data.frame()'? –