I have many text files
fr.txt
no.txt
sta.txt
sto.txt
I create a vector with filename as string
string <- c("fr","no","sta","sto")
And I would like to use for loop in R to use string as the variable names and to read the corresponding files.
for (type in c("fr","no","sta","sto")){type <- read.table(sprintf("%s.txt", type),header=TRUE)}
For example
fr <- read.table("fr.txt",header=TRUE)
no <- read.table("no.txt",header=TRUE)
sta <- read.table("sta.txt",header=TRUE)
How should I start with ? The above for loop failed to do what I want.