I have the following data structure (which was actually created by counting the occurences of “Result” with ddply):
Experiment Result Count
A 1 123
A 2 30
A 3 5
B 1 120
B 2 20
B 3 5
B 4 1
B 5 1
C 1 130
C 2 21
...
I want to create a similar data frame that groups (calculates sum) of all results that are greater than 2.
Expected outcome:
Experiment Result Count
A 1 123
A 2 30
A >2 5
B 1 120
B 2 20
B >2 7
C 1 130
C 2 21
...
Probably plyr can do this but I am new to R and have no idea how to use a custom condition (i.e. result 1,2,>2) and not just the distinct values of a column.
Note: I do not mind the name of the new bin (i.e., may be != ‘<2’).
1 Answer