l******9 发帖数: 579 | 1 I am working on data collection by R on Win7.
The given data is:
var1 var2 value
I need to do grouping by var1 and then for each var1 , do grouping by var2.
Then, the output is column vectors of values that are associated with the
same var1 and var2. Here, var1 and var2 are like keys.
Example,
var1 var2 value
1 56 649578
2 17 357835
1 88 572397
2 90 357289
1 56 427352
2 17 498455
1 88 354623
2 90 678658
The result should be
var1 var2 value
1 56 649578
1 56 427352
1 88 354623
1 88 572397
2 17 357835
2 17 498455
2 90 357289
2 90 678658
And, I need to print the values in a csv file as
For var 1 as 1:
649578 354623
427352 572397
For var 1 as 2:
357835 357289
498455 678658
And, I also need to print the values in a csv file as
For var 1 = 1:
1 56 649578
1 56 427352
1 88 354623
1 88 572397
For var1 = 2:
2 17 357835
2 17 498455
2 90 357289
2 90 678658
How to do it ?
I found some posts, which are not directly useful.
Any help would be appreciated. | c********h 发帖数: 330 | 2 order() in R could handle ordering several variables |
|