I am a new user, and i am trying to sort out a data frame. I have for example bins of data. Within each bin i have multiple counts of animals and the depths at which these count were taken. How would I summarise this to being only the maximum count per bin alongisde the corresponding height (but not the maximum depth - i want the depth at which the maximum number of animals occurs). Thank you [[alternative HTML version deleted]]
I am a new user, and i am trying to sort out a data frame. I have for example bins of data. Within each bin i have multiple counts of animals and the depths at which these count were taken. How would I summarise this to being only the maximum count per bin alongisde the corresponding height (but not the maximum depth - i want the depth at which the maximum number of animals occurs). Thank you -- View this message in context: http://r.789695.n4.nabble.com/Sorting-Dataframes-tp3580075p3580075.html Sent from the R help mailing list archive at Nabble.com.
SamiC wrote:> > I am a new user, and i am trying to sort out a data frame. > > I have for example bins of data. Within each bin i have multiple counts > of animals and the depths at which these count were taken. How would I > summarise this to being only the maximum count per bin alongisde the > corresponding height (but not the maximum depth - i want the depth at > which the maximum number of animals occurs). > > > Thank you >Post a small example that contains sufficient complexity to represent the problem and also post what you consider to be the correct answer. -- David. -- View this message in context: http://r.789695.n4.nabble.com/Sorting-Dataframes-tp3580075p3580521.html Sent from the R help mailing list archive at Nabble.com.
So I have figured out how to do it via a series of loops and conditions, but i am thinking there must be a quicker way to do it. an example. Bin Depth Fish to: Bin Depth MaxFish 1 4 2 1 8 24 1 8 24 2 8 21 1 12 4 3 12 33 2 4 3 2 8 21 2 12 2 3 4 12 3 8 2 3 12 33 -- View this message in context: http://r.789695.n4.nabble.com/Sorting-Dataframes-tp3580075p3581046.html Sent from the R help mailing list archive at Nabble.com.
Hello Samantha, I'm having some trouble understanding your question in terms of what's happening in R. Are these "bins" columns of a data.frame? Rows? It's helpful for us to have a small example to look at--for instance, you could create a small subset of your data called x, then type the command dump("x", file=stdout()) which will print an expression that will recreate the object x. Best, Ethan On Tue, Jun 7, 2011 at 9:42 AM, Cox, Samantha Lucy <s.cox.10 at aberdeen.ac.uk> wrote:> I am a new user, and i am trying to sort out a data frame. > > > > I have for example bins of data. ?Within each bin i have multiple counts of animals and the depths at which these count were taken. ?How would I summarise this to being only the maximum count per bin alongisde the corresponding height (but not the maximum depth - i want the depth at which the maximum number of animals occurs). > > > > Thank you > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > 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. >