Re: [R] Count values in a dataframe with respect to groups

2010-10-08 Thread Henrique Dallazuanna
mns to count > (val1 and val2)? > > > Betreff: Re: [R] Count values in a dataframe with respect to groups > > Try this: > > aggregate(val ~ grp, dta, length) > > On Fri, Oct 8, 2010 at 11:28 AM, Marcus Drescher wrote: > Dear all, > > I am looking for a fun

Re: [R] Count values in a dataframe with respect to groups

2010-10-08 Thread Felipe Carrillo
alifornia, USA - Original Message > From: Marcus Drescher > To: "r-help@r-project.org" > Sent: Fri, October 8, 2010 8:04:40 AM > Subject: Re: [R] Count values in a dataframe with respect to groups > > Thanks! It works great. > > One more question: how would I have

Re: [R] Count values in a dataframe with respect to groups

2010-10-08 Thread ONKELINX, Thierry
Have a look at table table(na.omit(dta)$grp) Untested! ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie & Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for Natur

Re: [R] Count values in a dataframe with respect to groups

2010-10-08 Thread Marcus Drescher
I am sorry for the typo, it is about counting two columns an skipping the NAs. How would I have to set the formula if I would have two columns to count (val1 and val2)? Betreff: Re: [R] Count values in a dataframe with respect to groups Try this: aggregate(val ~ grp, dta, length) On Fri

Re: [R] Count values in a dataframe with respect to groups

2010-10-08 Thread Marcus Drescher
Thanks! It works great. One more question: how would I have to set the formula if I would have the columns to count (val1 and val2)? Betreff: Re: [R] Count values in a dataframe with respect to groups Try this: aggregate(val ~ grp, dta, length) On Fri, Oct 8, 2010 at 11:28 AM, Marcus

Re: [R] Count values in a dataframe with respect to groups

2010-10-08 Thread Henrique Dallazuanna
Try this: aggregate(val ~ grp, dta, length) On Fri, Oct 8, 2010 at 11:28 AM, Marcus Drescher wrote: > Dear all, > > I am looking for a function to count values belonging to a class within a > dataframe (and ignore NAs). > > grp = c(1,1,1, 1,2, 2,2) > val = c(2,1,5,NA,3,NA,1) > > dta = data.fra