Re: [R] accessing dimension names

From: Moshe Olshansky <m_olshansky_at_yahoo.com>
Date: Tue, 18 Dec 2007 17:28:49 -0800 (PST)


To access your dimension idx you could do either assign("a",paste("dimnames(y)$x",idx,sep="")) or
eval(parse(text=paste("a<-dimnames(y)$x",idx,sep="")))

> I have a matrix y:
>
> > dimnames(y)
> $x93
> [1] "1" "2"
>
> $x94
> [1] "0" "1" "2"
> .................. so on (there are other
> dimensions as well)
>
>
>
> I need to access a particular dimension, but a
> random mechanism tells me
> which dimension it would. So, sometimes I might need
> to access
> dimnames(y)$x93, some other time it would be
> dimnames(y)$x94.. and so on.
> Now let that random dimension be idx, then
> dimnames(y)$paste('x',idx,sep='')
> doesn't work.
>
> Can anyone help?
>
> Thanks!
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



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. Received on Wed 19 Dec 2007 - 01:33:26 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 19 Dec 2007 - 02:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.