[R] convert strings to object names

Thomas Lumley
Thu, 19 Aug 2004 15:15:17 -0000

And this is all in the FAQ.

	-thomas


On Thu, 19 Aug 2004, Adaikalavan Ramasamy wrote:

>  assign("dat", get(paste("dat", no, sep="")))
>
> or simply
>
>  dat <- get(paste("dat", no, sep=""))
>
>
> On Thu, 2004-08-19 at 15:15, Gudrun Jonasdottir wrote:
> > Dear R-Help list,
> >
> > I have a problem with convertions of strings. I want to use the
function
> > "paste()" to create an object name and then use that
character string to
> > call on that object. So, for example:
> >
> > dat99 <- matrix(rbind(1,1,2),3,3)
> > no <- 99
> > dat <- paste("dat",no,sep="")
> > dat
> > [1] "dat99"
> >
> > What should I do to get the output
> >
> > dat
> >      [,1] [,2] [,3]
> > [1,]    1    1    1
> > [2,]    1    1    1
> > [3,]    2    2    2
> >
> > Cheers,
> > Gudrun
> >
> >
>
> ______________________________________________
> 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
>

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle