Hi all; It seemed to be easy at first, but I didn't manage to find the answer through the google search. I have a set of data for every second of the experiment, but I don't need such a high resolution for my analysis. I want to replace every 30 row of my data with their average value. And then save the new data set in a new csv file to be able to have a smaller excel data sheet. What is the command for combining certain number of data into their average value? Thank you -- Nasrin Pak MSc Student in Environmental Physics University of Calgary [[alternative HTML version deleted]]
There is no single command to do all of what you want. Read the posting guide for advice on how to ask questions that are more likely to receive helpful answers. The mean() function is a command for "combining certain number of data into their average value". The write.csv() function will create a new csv file. The aggregate() function may help. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 11/17/11 7:37 AM, "Nasrin Pak" <astronasrin at gmail.com> wrote:>Hi all; > >It seemed to be easy at first, but I didn't manage to find the answer >through the google search. I have a set of data for every second of the >experiment, but I don't need such a high resolution for my analysis. I >want >to replace every 30 row of my data with their average value. And then save >the new data set in a new csv file to be able to have a smaller excel data >sheet. What is the command for combining certain number of data into their >average value? > >Thank you > >-- >Nasrin Pak >MSc Student in Environmental Physics >University of Calgary > > [[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.
On Nov 17, 2011, at 10:37 AM, Nasrin Pak wrote:> Hi all; > > It seemed to be easy at first, but I didn't manage to find the answer > through the google search. I have a set of data for every second of > the > experiment, but I don't need such a high resolution for my analysis. > I want > to replace every 30 row of my data with their average value. And > then save > the new data set in a new csv file to be able to have a smaller > excel data > sheet. What is the command for combining certain number of data into > their > average value? >This aggregates mean values in groups of ten. > aggregate(data.frame(a=rnorm(100)), list(rep(1:10, each=10)), FUN=mean) Group.1 a 1 1 -0.59492893 2 2 0.20087525 3 3 -0.06310919 4 4 -0.60778424 5 5 -0.01435818 6 6 -0.01159243 7 7 0.05921309 8 8 -0.04881492 9 9 0.43796040 10 10 -0.02968688> Thank you > > -- > Nasrin Pak > MSc Student in Environmental Physics > University of Calgary > > [[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.David Winsemius, MD West Hartford, CT