title: Error in 1:x : argument of length 0
body: <p>I'm trying to read few files (like A, B, ...) in R, then for each file, iterate line by line, filter some rows using a certain cutoff, and save it in data.frame and later on make a plot. Instead of doing one by one, I tried to use nested loop and list, but it returns this error:</p>
  
  <pre><code>Error in 1:x : argument of length 0
  </code></pre>
  
  <h1>my code:</h1>
  
  <pre><code>A &lt;- read.delim("A.txt",header=F)
  B &lt;- read.delim("B.txt",header=F)
  C &lt;- read.delim("C.txt",header=F)
  D &lt;- read.delim("D.txt",header=F)
  
  
  mylist &lt;- list (
    "A"=A,
    "B"=B,
    "C"=C,
    "D"=D
    )
  
  #also tried mylist &lt;- c("A","B","C","D")   
  
  
  
  
  for (j in names(mylist)){
      x &lt;- nrow(j) 
      d &lt;- data.frame()
      for (i in 1:x){
        if(j[i,1]&lt;0){
          d &lt;- rbind(d, (j[i,]))
        }
        else {next}
      }
  
      #make plot
  
      }
  </code></pre>