How to resolve dcast error with reshape2 package in R?

前端 未结 1 1749
傲寒
傲寒 2021-01-19 04:52

I\'m trying to convert some data from long to wide using the reshape2 package, but I\'m getting an error that I haven\'t been able to resolve. In the example below, I\'ve cr

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-19 05:23

    Just put credits in quotation marks:

    df.wide = dcast(df, ID ~ subj, value.var="credits", fun.aggregate=sum)
    df.wide
       ID CHEM ENGL HIST MATH
    1 100    6    3    3    3
    2 101    3    6    3    3
    3 102    3    3    6    3
    4 103    3    3    3    6
    

    0 讨论(0)
提交回复
热议问题