[R] automatically generate the output name of my "for" loops

Petr PIKAL petr.pikal at precheza.cz
Mon Jun 13 18:02:44 CEST 2011


Hi

r-help-bounces at r-project.org napsal dne 13.06.2011 17:35:29:

> jiliguala <jiliguala at mail.com> 
> 
> really thanks for helping.
> 
> i just did just like what Petr Pikal said,
> but it appeared some error like this:
> 
> There were 50 or more warnings (use warnings() to see the first 50):
> 
> Warning messages:
> 1: In group[i] <- which(k1$cluster == i) :
>   number of items to replace is not a multiple of replacement length
> 2: In group[i] <- which(k1$cluster == i) :
>   number of items to replace is not a multiple of replacement length
> 3: In group[i] <- which(k1$cluster == i) :
>   number of items to replace is not a multiple of replacement length
> ...
> ...
> ...
> 
> and some solution for that, thanks..

Do you want to mimic some C style programming? If yes you'd rather consult 
some documentation coming with R.

Without knowing much about your code the warning message tells you that 
you want to fill six position egg holder with 10 eggs and R correctly 
tells you a warning that it put 6 eggs in the holder and threw away 
remaining four. 

If this is what you intended, you does not need to worry. If you wanted 
something different you need to reveal some more info to us.

x<-1:5
z<-rep(NA, 4)
z[1:4]<-x
Warning message:
In z[1:4] <- x :
  number of items to replace is not a multiple of replacement length

Regards
Petr

> 
> --
> View this message in context: 
http://r.789695.n4.nabble.com/automatically-
> generate-the-output-name-of-my-for-loops-tp3592160p3594096.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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.



More information about the R-help mailing list