[R] for loop to list files

Beatriz R. Gonzalez Dominguez aguitatierra at hotmail.com
Mon Apr 21 10:43:24 CEST 2014


Dear all,

I'm trying to create a loop to select a series of files into my computer 
but I haven't been successful until now. I've looked into different 
possibilities but none has worked. I'd appretiate if you could help me 
by providing me with some ideas.

Basically what  I'd like to do is to create a character string variable 
[1:5], same as the one that could be obtained with 'list.files', but 
using a 'for' loop.

This is one of the things I've tried but obviously doesn't yield the 
results I would like:

for(i in 1976:1981){
   PE.files_01_7681 <- paste("val_mapped_petpe_", i, "01.txt", sep="")
  paste(PE.files_01_7681[i])
}

Many thanks!




More information about the R-help mailing list