Dear all, I would like to create the following sequence of numbers 1 2 2 3 3 3 3 4 4 4 4 4 4 4 4 and so on (actually I double the number of same elements).... the reason is that I want then to feed the sequence above to tapply(myVector, weirSeq, FUN = mean) and then average over those... Could you please provide some guidance how I can create such a sequence in R? Regards Alex [[alternative HTML version deleted]]
rep(1:4, c(1,2,4,8)) rep has additional arguments that might be helpful to you. ?rep On Thu, Mar 22, 2012 at 1:03 PM, Alaios <alaios@yahoo.com> wrote:> Dear all, > I would like to create the following sequence of numbers > 1 2 2 3 3 3 3 4 4 4 4 4 4 4 4 and so on (actually I double the number of > same elements).... > > the reason is that I want then to feed the sequence above to > tapply(myVector, weirSeq, FUN = mean) > > and then average over those... > > Could you please provide some guidance how I can create such a sequence in > R? > > Regards > Alex > > [[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. > >[[alternative HTML version deleted]]
On 22.03.2012 18:03, Alaios wrote:> Dear all, > I would like to create the following sequence of numbers > 1 2 2 3 3 3 3 4 4 4 4 4 4 4 4 and so on (actually I double the number of same elements).... > > the reason is that I want then to feed the sequence above to > tapply(myVector, weirSeq, FUN = mean) > > and then average over those... > > Could you please provide some guidance how I can create such a sequence in R?We do not answer homework questions. Uwe Ligges> Regards > Alex > > [[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.