Sonia Mehault pisze: > Hello, > > I have a dataframe of say 20 lines with one line per individual. I want to > group these 20 individuals > by length class (eg. of 5cm) and get the mean value of all the other > variables (eg VarA and VarB) for each length class > > My dataframe is as follow: > > Length <- 10:30 > VarA <- seq(1000,1200,10) > VarB <- seq(500,700,10) > Data <- cbind(Length,VarA,VarB) > > > And I want to get something like: > > > Length Class Mean VarA Mean VarB > [10-15[ 1020 520 > [15-20[ 1070 570 > [20-25[ 1120 620 > [25-30] 1175 675 > > > Would you have any suggestions how to do that ? > Many thanks. > > > Sonia. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > Sonia!
use cut fuction. Create two wectos with intervals and lables acording documentation. Very simple and fast solution. Jarek ______________________________________________ R-help@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.