[R] data.frame-question

Michael Graber michael_graber at gmx.de
Tue Oct 25 21:44:57 CEST 2005


Dear R-List,
I am very new to R and programming itself, so my question may be easy to 
answer for you.
I tried a lot and read through the manuals, but I still have the 
following problem:
I have 2 data-frames:
Number<-as.numeric (Number)
Name<-as.character (Name)
TAB1<-data.frame (Name,Number)
- it looks like this:-
Name Number
A 2
A 3
A 6
B 8
B 12
B 7
C 8
D 90
E 12
E 45
â€¦
Name_singular<-as.character (Name_singular)
TAB2<-data.frame (Name_singular)
# it looks like this:
Name_singular
A
B
C
D
E
-My result should be a data-frame, where the first column is 
Name_singular and the second column should be the sum of the numbers 
where Name ==Name_singular.-
For example:
TAB3:
Name_singular Sum
A 11
B 27
â€¦
- I tried it with for-loops, but I think there must be an easier way.-
I would be very grateful for your help,


Michael Graber




More information about the R-help mailing list