[BioC] object programming problem

Kasper Daniel Hansen k.hansen at biostat.ku.dk
Tue Mar 1 17:37:52 CET 2005

You can use get(name, environment) with name a character string. So the 
length example can be solved with
  length(get("ag")) # the default environment is the workspace

In case name is a vector (and not just a single name), you can use 
mget(name.vector, environment) which will return a list of objects. This 
is basically what you use to access the annotation objects in 

For the whole deal: if you want to do the reverse: create an object of 
name "name" with a value, you use assign(name, value, environment). In 
this case the vectorized version is called multiassign.


On Tue, Mar 01, 2005 at 01:32:49PM +0000, Ian Jeffery wrote:
> Hi,
>     I have a programming problem that I have ran into once or twice before
> Using the command ls returns the names of the files in the active R
> environment. I need to use the data contained in these files but ls() only
> returns the names of the files. I'm wondering if there is a function that
> can be used to access the data?
> An example of the problem is as follows.
> > ag<-1:10
> > bu<-c('h','e','l','p')
> > Ci<-ag
> > length(ag)
> [1] 10
> > length(ls()[1])
> [1] 1
> > ls()[1]
> [1] "ag"
> The length of ag is 10 but the length of its name is 1. How do I get the
> length command to look at the data instead of the name?
> Thanks
>      Ian
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor

Kasper Daniel Hansen, Research Assistant
Department of Biostatistics, University of Copenhagen

More information about the Bioconductor mailing list