[R] Warning message with aggregate function

Xingwang Ye xingwang.ye at gmail.com
Thu Sep 6 15:48:44 CEST 2007


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.
>



More information about the R-help mailing list