[R] get the content of object in ls()?

Liaw, Andy andy_liaw at merck.com
Wed Jul 27 20:58:31 CEST 2005


See ?get.

Andy

> From: Meng Cheng
> 
> Hi,
> I am wirting a R script to process some data routinely and 
> have a problem 
> when try to get the content of object in ls()?
> Here is the script:
> > ls()
> [1] "a" "b"
> [3] "files.num" "fll92_1a_gpr"
> [5] "fll92_1a_gpr_norm" "fll92_1a.gpr.norm.scale"
> [7] "fname" "fullnames"
> [9] "gal" "galfile"
> [11] "i" "readGalfile2"
> [13] "sample1" "ttest1"
> > grep("_gpr$",ls())
> [1] 4
> > ls()[4]
> [1] "fll92_1a_gpr"
> > class(ls()[4])
> [1] "character"
> > class(fll92_1a_gpr)
> [1] "marrayRaw"
> attr(,"package")
> [1] "marray"
> 
> I use the regular expression to get the name of the object I 
> want, which is 
> fll92_1a_gpr, the fourth element in ls() list. 
> But i can't get the content of that object using ls()[4], 
> which gives me a 
> character object(having a double quote). 
> I can still get the data in fll92_1a_gpr by typing 
> fll92_1a_gpr. But this 
> can't be done if I want to implement it in a executable R script.
> Anyone has an idea how to solve this?
> 
> meng
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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
> 
> 
>




More information about the R-help mailing list