Hi R-Experts, I have a vector of length 72. I want to break it into 12 parts and want to take standerd deviation of each group. Please help me in this regard. Thanks, Sumanta. --------------------------------- [[alternative HTML version deleted]]
sumanta basak wrote:> Hi R-Experts, > > I have a vector of length 72. I want to break it into 12 parts and want to take standerd deviation of each group. Please help me in this regard.x <- 1:72 apply(matrix(x, ncol=12), 2, sd) Uwe Ligges> Thanks, > Sumanta. > > > --------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Try this: tapply(x, cut(x, 12), sd) On 4/28/06, sumanta basak <basaksumanta at yahoo.com> wrote:> Hi R-Experts, > > I have a vector of length 72. I want to break it into 12 parts and want to take standerd deviation of each group. Please help me in this regard. > > Thanks, > Sumanta. > > > --------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
You didn't say _how_ you want the vector to be broken up, so you get two different answers from Uwe and Gabor. Uwe's answer group every six elements into one group, in the order they appear in the vector (which, BTW, can be simplified to just sd(matrix(x, ncol=12)). Gabor's answer put the smallest six into one group, the next smallest six into the second group and so on. You'll have to decide which is the one you want. Andy From: sumanta basak> > Hi R-Experts, > > I have a vector of length 72. I want to break it into 12 > parts and want to take standerd deviation of each group. > Please help me in this regard. > > Thanks, > Sumanta. > > > --------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >