[R] merge words=data name

Gabor Grothendieck ggrothendieck at gmail.com
Sun Feb 11 22:56:17 CET 2007


Try this:

my.data <- M3[[sprintf("N%04d", 1)]]

On 2/11/07, Robert McFadden <robert-mcfadden at o2.pl> wrote:
> I would like to merge two parts of words to get a name of the data. First
> M3$N (invariable) and second is a number from 0001 to 3003 -
> M3$N0001,M3$N0002,...,M3$N3003. For example if I do it like this:
> my.data <- paste("M3$N",2456,sep="")
> I get
> > my.data
> [1] "M3$N2456"
> But I want to get something equivalent to
> my.data<- M3$N2456
>
> Is there any way to do it?
> It's important, because the second part are randomly chosen.
> (The data that I would like to extract are in package Mcomp.)
>
> Thanks in advance,
> Rob
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list