How to use a string as an environment name in mget?
1
0
Entering edit mode
Jarno Tuimala ▴ 140
@jarno-tuimala-1650
Last seen 10.2 years ago
Dear all, Is it possible to use a string as an environment name in mget? I was trying to do this with the following script, but it says that the second argument for mget is not an environment. Well, I know it isn't, since it was generated using paste function, so it's class is character. > genes<-c("1007_s_at", "1053_at", "117_at", "121_at") > chip<-"hgu133a" > library(package=chip, character.only=T) > env<-paste(chip, "REFSEQ", sep="") > refseq<-as.vector(unlist(mget(genes, envir=env))) Error in mget(x, envir, mode, ifnotfound, inherits) : second argument must be an environment The following works fine: > refseq<-as.vector(unlist(mget(genes, envir=hgu133aREFSEQ))) But, I'm trying to put together a script I could easily just source for different datasets, so I would like to avoid typing the name of the environment every time (I read the name of the Affymetrix chip set from a second file in the actual script). Best regards, Jarno Tuimala
• 1.8k views
ADD COMMENT
0
Entering edit mode
@wolfgang-huber-3550
Last seen 3 months ago
EMBL European Molecular Biology Laborat…
Hi, get(env) will be an environment if env is the name of an environment. Best wishes Wolfgang ------------------------------------------------------------------ Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber Jarno Tuimala wrote: > Dear all, > > Is it possible to use a string as an environment name in mget? I was > trying to do this with the following script, but it says that the second > argument for mget is not an environment. Well, I know it isn't, since it > was generated using paste function, so it's class is character. > >> genes<-c("1007_s_at", "1053_at", "117_at", "121_at") >> chip<-"hgu133a" >> library(package=chip, character.only=T) >> env<-paste(chip, "REFSEQ", sep="") >> refseq<-as.vector(unlist(mget(genes, envir=env))) > Error in mget(x, envir, mode, ifnotfound, inherits) : > second argument must be an environment > > The following works fine: > >> refseq<-as.vector(unlist(mget(genes, envir=hgu133aREFSEQ))) > > But, I'm trying to put together a script I could easily just source for > different datasets, so I would like to avoid typing the name of the > environment every time (I read the name of the Affymetrix chip set from a > second file in the actual script). > > Best regards, > Jarno Tuimala
ADD COMMENT

Login before adding your answer.

Traffic: 512 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6