[R] data.frame-question

bogdan romocea br44114 at gmail.com
Tue Oct 25 21:59:48 CEST 2005


Welcome to R. See
   ?merge
then
   ?aggregate
or
   require(Hmisc)
   ?summarize
or
   ?by
You can probably find many examples in the archives, if needed.


> -----Original Message-----
> From: Michael Graber [mailto:michael_graber at gmx.de]
> Sent: Tuesday, October 25, 2005 3:45 PM
> To: R-Mailingliste
> Subject: [R] data.frame-question
>
>
> 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 at 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
>




More information about the R-help mailing list