Re: [R] count values

2013-04-18 Thread arun
 vec1<- c(0,1,1,1,2,2,2,3,3) length(unique(vec1[vec1!=0])) #[1] 3  vec2<- c(0,2,2,3)  length(unique(vec2[vec2!=0])) #[1] 2 A.K. >Hi. I have a new question. >I need count the different numbers in a vector,but different of zero. >I mean,if I have c(0,2,2,3) the result is 2. If the  >vector is c(

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
spronkelijk bericht- > Van: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] Namens Marcus Drescher > Verzonden: vrijdag 8 oktober 2010 16:29 > Aan: r-help@r-project.org > Onderwerp: [R] Count values in a dataframe with respect to groups > > Dear all, >

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

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

2010-10-08 Thread Marcus Drescher
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.frame(grp=grp, val=val) The result should look like: grp count 13 22 At the moment, I am trying to find a fun