Dear R helpers:
      I have tried many times to find some way to read a list into R. But I faid. Here is an example:
      I have a file 'List.txt' which includes data as follows:
[[1]]
  [1] 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0
 [19] 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

[[2]]
 [1] 0.0000000 0.5000000 0.0000000 0.0000000 0.5000000 0.0000000 0.0000000
 [8] 0.0000000 0.0000000 0.0000000

[[3]]
  [1] 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
 [19] 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.5 0.0 0.5 0.0 0.0 0.0 0.0

'List.txt' was output by 'sink' from R.
I try to read 'List.txt' into R.
First I tried 'dget', I got
> dget('Vlist300.txt')
Error in parse(file = file) : Vlist300.txt: unexpected '[[' at
1: [[

Then I tried 'scan',
>scan('List.txt', what='list')
Read 86 items
 [1] "[[1]]"     "[1]"       "0.0"       "0.0"       "0.0"       "0.0"
 [7] "0.0"       "0.0"       "0.0"       "0.0"       "0.0"       "0.0"
[13] "0.0"       "0.0"       "0.0"       "0.0"       "0.5"       "0.0"
[19] "0.0"       "0.0"       "[19]"      "0.0"       "0.0"       "0.0"
[25] "0.0"       "0.0"       "0.0"       "0.0"       "0.0"       "0.0"
[31] "0.0"       "0.0"       "0.0"       "0.0"       "0.0"       "0.0"
[37] "0.0"       "0.0"       "[[2]]"     "[1]"       "0.0000000" "0.5000000"
[43] "0.0000000" "0.0000000" "0.5000000" "0.0000000" "0.0000000" "[8]"
[49] "0.0000000" "0.0000000" "0.0000000" "[[3]]"     "[1]"       "0.0"
[55] "0.0"       "0.0"       "0.0"       "0.0"       "0.0"       "0.0"
[61] "0.0"       "0.5"       "0.0"       "0.0"       "0.0"       "0.0"
[67] "0.0"       "0.0"       "0.0"       "0.0"       "0.0"       "[19]"
[73] "0.0"       "0.0"       "0.0"       "0.0"       "0.5"       "0.0"
[79] "0.0"       "0.5"       "0.0"       "0.5"       "0.0"       "0.0"
[85] "0.0"       "0.0"

Unfortunately I can't find any function to read 'List.txt' into R and to give me the right format as in List.txt. Do you know if there's a function that can read 'List.txt' into R and keep the format as follows?

[[1]]
  [1] 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0
 [19] 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

[[2]]
 [1] 0.0000000 0.5000000 0.0000000 0.0000000 0.5000000 0.0000000 0.0000000
 [8] 0.0000000 0.0000000 0.0000000

[[3]]
  [1] 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
 [19] 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.5 0.0 0.5 0.0 0.0 0.0 0.0

  I appreciate any help!!
Best,
Hua


	[[alternative HTML version deleted]]


