Transposing data frames

后端 未结 1 543
心在旅途
心在旅途 2020-12-05 16:08

Happy Weekends.

I\'ve been trying to replicate the results from this blog post in R. I am looking for a method of transposing the data without using t,

相关标签:
1条回答
  • 2020-12-05 16:17

    Using tidyr, you gather all the columns except the first, and then you spread the gathered columns.

    Try:

    library(dplyr)
    library(tidyr)
    data %>%
      gather(var, val, 2:ncol(data)) %>%
      spread(Series.Description, val)
    
    0 讨论(0)
提交回复
热议问题