[R] skip reading a file.

Alaios alaios at yahoo.com
Tue May 24 12:00:57 CEST 2011


Dear all,
I would like to do read a bunch of files that have the following format

file_i_j
examples:
file_1_1
file_1_2
file_1_3
file_2_1
file_2_2
file_3_1
file_3_2
file_3_3
file_3_4
file_4_1
file_4_2

The integer i goes from 1 to 100
and the integer j starts from 1 and stops somewhere between 1 and 100, which I do not know in advance

Usually I would be able to solve this by having a nested loop

(algorithmic syntax below, not sure if is R okay)
for i in (c(1:100))
  for j in (c(1:100))
    store[i,j]<- read file_i_j
   end
end

the problem with that is that R will halt when j take a value that refers to a non existing value. Thus I want to have a good way to break the nested loop and continue with the outer one. How I can do that?

Best Regards
Alex



More information about the R-help mailing list