Dear all, When I use aggregate function as: attach(warpbreaks) aggregate(warpbreaks[, 1], list(wool = wool, tension = tension), sum) The results are right but I get a warning message: "number of items to replace is not a multiple of replacement length." BTW: I use R version 2.4.1 in Ubuntu 7.04. Your kind solutions will be great appreciated. Best wishes Yours, sincerely, Xingwang Ye
If I use your code, I don't get the error. Maybe you stripped your code to create a minimal, self-contained, reproducible code? Perhaps in your original code, you store the result of the aggragate function in a dataframe of a different size than the results? Bart felix-36 wrote:> > Dear all, > When I use aggregate function as: > > attach(warpbreaks) > aggregate(warpbreaks[, 1], list(wool = wool, tension = tension), sum) > > The results are right but I get a warning message: > "number of items to replace is not a multiple of replacement length." > > BTW: I use R version 2.4.1 in Ubuntu 7.04. > > Your kind solutions will be great appreciated. > > Best wishes > > Yours, sincerely, > Xingwang Ye > > ______________________________________________ > 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 > and provide commented, minimal, self-contained, reproducible code. > >-- View this message in context: http://www.nabble.com/Warning-message-with-aggregate-function-tf4390252.html#a12518160 Sent from the R help mailing list archive at Nabble.com.
Xingwang Ye wrote:> Dear all, > When I use aggregate function as: > > attach(warpbreaks) > aggregate(warpbreaks[, 1], list(wool = wool, tension = tension), sum) > > The results are right but I get a warning message: > "number of items to replace is not a multiple of replacement length." > > BTW: I use R version 2.4.1 in Ubuntu 7.04.Does not happen for me, neither with R-2.4.1 nor with recent versions of R. Maybe you have redefined one of the used objects (aggregate, warpbreaks, wool, tension, sum) in one of your environments? BTW: Is is always a bad idea to make much use of attach()... Uwe Ligges> Your kind solutions will be great appreciated. > > Best wishes > > Yours, sincerely, > Xingwang Ye > > ______________________________________________ > 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 > and provide commented, minimal, self-contained, reproducible code.
Thank you for sharing your experience. The example data I used is from help for "by" function, so every one could have a try. After using $, the warning message disappeared: aggregate(warbreaks[,1], list(wool = warbreaks$wool, tension=warbreaks$tension),sum) Another approach may be to restart your R. Xingwang Ye Uwe Ligges wrote:> > > Xingwang Ye wrote: >> Dear all, >> When I use aggregate function as: >> >> attach(warpbreaks) >> aggregate(warpbreaks[, 1], list(wool = wool, tension = tension), sum) >> >> The results are right but I get a warning message: >> "number of items to replace is not a multiple of replacement length." >> >> BTW: I use R version 2.4.1 in Ubuntu 7.04. > > > Does not happen for me, neither with R-2.4.1 nor with recent versions > of R. Maybe you have redefined one of the used objects (aggregate, > warpbreaks, wool, tension, sum) in one of your environments? > > BTW: Is is always a bad idea to make much use of attach()... > > Uwe Ligges > > >> Your kind solutions will be great appreciated. >> >> Best wishes >> >> Yours, sincerely, >> Xingwang Ye >> >> ______________________________________________ >> 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 >> and provide commented, minimal, self-contained, reproducible code. >