I’m trying to load multiple GSM files into R via a loop, but I think that I’m missing something obvious.
#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
}
You can use assign()
:
for (i in 971940:971948){
GSMName <- paste("GSM", i, sep = "")
assign(GSMName, getGEO(GSMName, destdir="."))
}