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

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Thu 28 Jul 2005 - 04:58:31 EST


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@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
>
>
>



R-help@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 Received on Thu Jul 28 05:02:23 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:34:06 EST