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

Petr PIKAL petr.pikal at precheza.cz
Mon Jun 13 10:51:03 CEST 2011


Hi

r-help-bounces at r-project.org napsal dne 13.06.2011 05:21:23:

> Re: [R] automatically generate the output name of my "for" loops
> 
> ?paste
> something like...
> paste (group, i, sep="_")
> 

I believe that better idea is to use list, with which you can work further 
much more efficiently.

lll<- vector("list", 100)

for (i in 1:100) {

lll[i] <- some computation

}

Regards
Petr


> 
> 
> jiliguala wrote:
> > 
> > Hello R users, 
> > 
> > I am new to R and am having difficulty with the output name of my 
"for"
> > loops. 
> > 
> > here is the problem:
> > 
> > 
> > for (i in c(1:100))
> > {
> > the name of the groups <- which(k1$cluster==i)
> > }
> > 
> > how can it automatically generate the name for 100 cluster(just like
> > group_1, group_2...)? what should i put in the bold letter place?
> > really thank you for helping me
> > 
> > Daniel
> > 
> 
> --
> View this message in context: 
http://r.789695.n4.nabble.com/automatically-
> generate-the-output-name-of-my-for-loops-tp3592160p3593123.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