用循环将多个GSM文件加载到R中?

问题描述:

我想通过循环将多个GSM文件加载到R,但我认为我错过了一些明显的东西。用循环将多个GSM文件加载到R中?

#Use i to loop through NCBI files GSM9714940 through GSM971948 

for (i in 971940:971948){ 
    (GSMName <- paste("GSM", i, sep = "")) #Define the actual file name as found on NCBI 
    GSMName <- getGEO(GSMName, destdir=".") #Use GSMName variable to pull data from NCBI 
    #This doesn't work b/c I'm using a variable to redefine itself, but 
    #I need the NCBI file name to also be the variable name 
    } 

您可以使用assign()

for (i in 971940:971948){ 
    GSMName <- paste("GSM", i, sep = "") 
    assign(GSMName, getGEO(GSMName, destdir=".")) 
} 
+0

好极了!我曾尝试assign(),但没有正确格式化它。谢谢! – user8121557

+0

我很高兴它的工作。如果你对答案满意,你会介意接受吗? – Bea