[R] Warning: number of items to replace is not a multiple of replacement length
Yves Magliulo
ym at climpact.com
Wed Sep 29 16:00:47 CEST 2004
hi,
that means you're doing operation whith matrix or dataframe with row or
column with different length. this can be a real reason to care about
and sometimes it could be an error and not only a warning.
you'd better adjust the length of your vector (array) to be the same in
order to avoid this warning and be sure you're doing excatly what you
want.
here's a sample of what i meant.
> toto=matrix(0,5,5)
> toto
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0
[2,] 0 0 0 0 0
[3,] 0 0 0 0 0
[4,] 0 0 0 0 0
[5,] 0 0 0 0 0
> tata=c(1,2,3)
> toto[,1]=tata
Error in "[<-"(*tmp*, , 1, value = tata) :
number of items to replace is not a multiple of replacement
length
here's the correct syntax
> toto[1:length(tata)]=tata
Le mer 29/09/2004 à 15:03, Mag. Ferri Leberl a écrit :
> What does this warning mean precisely?
> Is there any reason to care about it?
> Can I Avoid it by another way of programming?
> Thank you in advance.
>
> ______________________________________________
> 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
--
------
Yves Magliulo <ym at climpact.com>
R&D Engineer, CLIMPACT
Tel. : +33 (0) 1 44 27 34 31
Fax. : +33 (0) 1 44 27 49 96
Universite Pierre et Marie Curie
Boite 101 - Tour 45 - 5eme etage - Couloir 45/46
4 place Jussieu, 75252 Paris CEDEX 05, France
More information about the R-help
mailing list