[R] Conditional selection of rows
Gabor Grothendieck
ggrothendieck at myway.com
Tue Nov 9 03:58:35 CET 2004
F Z <gerifalte28 <at> hotmail.com> writes:
:
: Hi,
:
: I have a data.frame with several variables and 50,000 observations.
: i.e.
: data[1:2,1:7]
: Iteration Day Production.Type tsUSusc tsASusc tsULat tsALat
: 1 0 Generic 17965 8833053 0 0
: 1 1 Generic 17965 8833053 0 0
: .
: .
: .
: 1 199 Generic 17237 8141028 26 23131
: 2 127 Generic 15828 7307583 92 63463
:
: I would like to extract only the observations (rows) for the last "day" for
: each "iteration" and store them in a data frame.
:
Try this:
do.call("rbind", by(data, dat$Iteration, tail, 1))
More information about the R-help
mailing list