Dax
2009-Aug-13 14:11 UTC
[R] How to get the n (number of observations) per conditional group
Hello all, I have a huge data set that I'm cleaning up a bit. I am extracted the means per condition, but also need to get the n. Strangely enough I am unable to find a function that could actually pull this off. I am unable to use replications or count the rows using nrow. What I am trying to obtain is the number of observations fitting something along the lines of "data$total[data$spp==1&data$gyro==1&data $salinity==0&data$day==i]" Can anyone help me?
Erik Iverson
2009-Aug-13 15:34 UTC
[R] How to get the n (number of observations) per conditional group
We will only be able to help if you provide a reproducible example! I'm sure this is a simple one-liner, but it's hard to tell from your example what it should be. The functions table, length, tapply, and/or nrow may play a part though. -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Dax Sent: Thursday, August 13, 2009 9:11 AM To: r-help at r-project.org Subject: [R] How to get the n (number of observations) per conditional group Hello all, I have a huge data set that I'm cleaning up a bit. I am extracted the means per condition, but also need to get the n. Strangely enough I am unable to find a function that could actually pull this off. I am unable to use replications or count the rows using nrow. What I am trying to obtain is the number of observations fitting something along the lines of "data$total[data$spp==1&data$gyro==1&data $salinity==0&data$day==i]" Can anyone help me? ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
John Kane
2009-Aug-13 17:14 UTC
[R] How to get the n (number of observations) per conditional group
?length --- On Thu, 8/13/09, Dax <rienk.doetjes at gmail.com> wrote:> From: Dax <rienk.doetjes at gmail.com> > Subject: [R] How to get the n (number of observations) per conditional group > To: r-help at r-project.org > Received: Thursday, August 13, 2009, 10:11 AM > Hello all, > > I have a huge data set that I'm cleaning up a bit. I am > extracted the > means per condition, but also need to get the n. Strangely > enough I am > unable to find a function that could actually pull this > off. I am > unable to use replications or count the rows using nrow. > > What I am trying to obtain is the number of observations > fitting > something along the lines of > "data$total[data$spp==1&data$gyro==1&data > $salinity==0&data$day==i]" > > Can anyone help me? > > ______________________________________________ > R-help at r-project.org > mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. >__________________________________________________________________ [[elided Yahoo spam]]
Dax
2009-Aug-13 18:21 UTC
[R] How to get the n (number of observations) per conditional group
I found a work-around by just simply getting the sum of the conditional values and dividing this by the mean. It's not elegant but it works On Aug 13, 3:11?pm, Dax <rienk.doet... at gmail.com> wrote:> Hello all, > > I have a huge data set that I'm cleaning up a bit. I am extracted the > means per condition, but also need to get the n. Strangely enough I am > unable to find a function that could actually pull this off. I am > unable to use replications or count the rows using nrow. > > What I am trying to obtain is the number of observations fitting > something along the lines of "data$total[data$spp==1&data$gyro==1&data > $salinity==0&data$day==i]" > > Can anyone help me? > > ______________________________________________ > R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Seemingly Similar Threads
- vector("integer", length) : vector size specified is too large
- increase number of ticks on x axis of dates
- Setting maximum value of the legend on an image.plot and animation
- assign()ing within apply
- Degrees of Freedom Not Allocated to Residuals in Reduced Model