2017-06-06 63 views
0

我想通過循環將多個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 
    } 

回答

0

您可以使用assign()

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

好極了!我曾嘗試assign(),但沒有正確格式化它。謝謝! – user8121557

+0

我很高興它的工作。如果你對答案滿意,你會介意接受嗎? – Bea