Hi Chris Chris Stubben wrote: >> Finally I would like to have a data.frame t2 which only contains the >> entries of the last measurements. >> > > You could also use aggregate to get the max year per plate then join that back > to the original dataframe using merge on year and plate (common columns in > both > dataframes). >
Thanks for the idea to use aggregate and merge - as I like SQL, this seems to be a nice approach. Rainer > > > x<-data.frame(id=(1:8), plate=c(15,15,15,20,20,33,43,43), > year=c(2004,2005,2006,2004,2005,2004,2005,2006), > height=c(0.40,0.43,0.44,0.90,0.94,0.15,0.30,0.38)) > > merge(x, aggregate(list(year=x$year), list(plate=x$plate), max)) > > > plate year id height > 1 15 2006 3 0.44 > 2 20 2005 5 0.94 > 3 33 2004 6 0.15 > 4 43 2006 8 0.38 > > ______________________________________________ > [email protected] 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. -- NEW EMAIL ADDRESS AND ADDRESS: [EMAIL PROTECTED] [EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Leslie Hill Institute for Plant Conservation University of Cape Town Rondebosch 7701 South Africa Fax: +27 - (0)86 516 2782 Fax: +27 - (0)21 650 2440 (w) Cell: +27 - (0)83 9479 042 Skype: RMkrug email: [EMAIL PROTECTED] [EMAIL PROTECTED] ______________________________________________ [email protected] 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.
