[R] using for variable as rowname

David Winsemius dwinsemius at comcast.net
Thu Sep 18 21:11:25 CEST 2008


On Sep 18, 2008, at 6:25 AM, Ralikwen wrote:

>
> Thanks for your help,
> I didn't know where you can or can't use a for variable.
> Seems that I have to use rownames to do this anyway, so finally I  
> went for a
> more procedural solution:
> v=1:6
> for (a in 1:3){
>   for  (b in 4:5) {
>      v<-rbind(v,1+a+b:6+a+b)
                      ?^^?
Are your sure you are not running into problems with operator  
precedence? I would have imagined that":" should take precedence over  
"+". Check the R Language Definition sect 10.4.2. I am guessing you  
want more parens.

-- David Winsemius

>
>      rownames(v)[nrow(v)]= paste(a,b,sep=".")
>   }
> }
>
>
> Ralikwen wrote:
>>
>> Is there a way to use the cycle variable for rowname?
>>
>
> Thanks again.
> Balázs
> -- 
> View this message in context: http://www.nabble.com/using-for-variable-as-rowname-tp19533203p19549904.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