[R] Filling empty List in a FOR LOOP

michaelyb cel81009759 at gmail.com
Sun Apr 1 04:53:42 CEST 2012


Hello all,

I am trying to automate a list to be filled in a FOR LOOP.
Basically I need to load info from a third source and store it into a list.
This list goes to object "A"; The next list brought in by the LOOP goe to
object "B".. os on ans so forth.

When the iteration on the LOOP goes well (which means it isn't empty) I get
something like this:

A       
[[1]]
      [,1]   
 [1,] "1130"
 [2,] "1132"
 [3,] "1134"
 [4,] "1136"
 [5,] "1138"
 [6,] "1140"
 [7,] "1142"
 
[[2]]
      [,1]  
 [1,] "7.54"
 [2,] "6.55"
 [3,] "4.20"
 [4,] "3.50"
 [5,] "2.92"
 [6,] "2.42"
 [7,] "1.99"

However when the source is empty I get the following:

A
[[1]]
     [,1]

[[2]]
     [,1]

I need to store NA in the latter one. I have tried A[is.na(A)] but I get an
error message. 
Any help would be greatly appreciated.

Thank you in advance

--
View this message in context: http://r.789695.n4.nabble.com/Filling-empty-List-in-a-FOR-LOOP-tp4522694p4522694.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list