[R] data.frame-question

From: Michael Graber <michael_graber_at_gmx.de>
Date: Wed 26 Oct 2005 - 05:44:57 EST


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



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Oct 26 05:53:06 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:47 EST