[R] Subsetting depth profiles based on maximum depth

From: Sam Albers <tonightsthenight_at_gmail.com>
Date: Mon, 16 May 2011 15:32:30 -0700


Hello,

I am having a little trouble finding the right set of criteria to subset a portion of data. I am using an instrument that does depth profiles of a water column. The instrument records on the way down as well as the way up.

## So I am left with data like this:

dat <- data.frame(var = runif(11, 0, 10)) dat$depth <- c(1:5,5,5:1)

# So for the example
dat

## I am trying tp figure out how to subset the data so that all data
collected at the maximum depth and those collected on the way UP the water column are used and the data collected on the way DOWN through the water column are discarded. I got stumped by the fact that I can't just ask R for all values less than the maximum depth.

## So I've tried determining the row number of the maximum depth value and
discarding all values above that but so far I haven't been able to figure this out.

which.max(dat$depth)

Can anyone recommend a better strategy to figure this out?

Thanks so much in advance.

Sam

        [[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. Received on Mon 16 May 2011 - 22:50:54 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 16 May 2011 - 23:30:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive