What is the best way to transpose a data.frame in R and to set one of the columns to be the header for the new transposed table?

后端 未结 3 1828
南方客
南方客 2021-02-04 01:24

What is the best way to transpose a data.frame in R and to set one of the columns to be the header for the new transposed table? I have coded up a way to do this below. As I am

3条回答
  •  你的背包
    2021-02-04 02:04

    I had a similar problem to this -- I had a variable of factors in a long format and I wanted each factor to be a new column heading; using "unstack" from the stats library did it in one step. If the column you want as a header isn't a factor, "cast" from the reshape library might work.

提交回复
热议问题