Reshape data for values in one column

前端 未结 2 1332
别跟我提以往
别跟我提以往 2020-12-11 11:43

My data.frame looks like this

ID | test | test_result
1  |  B   |   10
2  |  A   |   9
3  |  A   |   11
4  |  C   |   7
5  |  F   |   5

And

2条回答
  •  孤城傲影
    2020-12-11 12:27

    Another solution using reshape function in base R.

    reshape(mydf, direction = 'wide', idvar = 'test', timevar = 'ID', 
      v.names = 'test_result', sep = "_")
    

    EDIT. I see that you have already tried reshape and it took too long. Can you provide more details on your actual data?

提交回复
热议问题