On Mon, 2011-05-16 at 13:18 -0700, olafgy wrote: > Hi there, > > I am trying to import 100 files with the names of "vpn 1 .dat" to "vpn 100 > .dat" > into a respective table calld vpn1 to vpn100. > > I therfore have created a variable X<-1:100 > > I not want to use X as a subtitute for the number in my filename, so that I > have to write only one function and it does the operation with all files. > > I have tried every combination i could imagine to include the string X into > the file name: > > vpn'X' , vpn"X" , vpn[X] , and so on, but R never did what I wanted it > too. > > vpn"X"<-read.table("vpn "X" .dat") > > So is there a way to do this in R??? or should I use an intirely new > aproach? > > Thanks for your Help!
How about paste() to form the strings and assign() to save your objects? > for(i in 1:100) assign(paste("vpn", i, sep=""), read.table(paste("vpn", i, ".dat"))) HTH, Jerome [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.