R newbie here. I know similar question have been asked before, but I just can't figure it out, so here it comes. I have a list of lists created by importing some datafiles from Matlab to R. I used lapply repeatedly to get top a list of datalists, and got it to look like this (extract for the first two datalists):
[[1]]
[[1]]$Data
, , 1
[,1]
opsy "1"
st List,11
nr 280
var1 Numeric,280
var2 Numeric,280
var3 Numeric,280
...
[[2]]
[[2]]$Data
, , 1
[,1]
opsy "2"
st List,11
nr 555
var1 Numeric,555
var2 Numeric,555
var3 Numeric,555
...
The str(my_top_list[[1]]$Data) looks as follows:
List of 15
$ : chr [1, 1] "1"
$ : chr [1, 1] "20191202T103203"
$ :List of 11
..$ : chr [1, 1] "Ariel"
..$ : num [1, 1:3] 255 255 255
..$ :List of 4
.. ..$ : num [1, 1] 72
.. ..$ : num [1, 1] 42
.. ..$ : num [1, 1] 30
.. ..$ : num [1, 1] 42
.. ..- attr(*, "dim")= int [1:3] 4 1 1
.. ..- attr(*, "dimnames")=List of 3
.. .. ..$ : chr [1:4] "reference" "fixation" "probabilities" "lotteryValues"
.. .. ..$ : NULL
.. .. ..$ : NULL
..$ :List of 4
.. ..$ : num [1, 1:2] 172 101
.. ..$ : num [1, 1:2] 71 55
.. ..$ : num [1, 1:2] 42 41
.. ..$ :List of 6
.. .. ..$ : num [1, 1:2] 64 64
.. .. ..$ : num [1, 1:2] 92 64
.. .. ..$ : num [1, 1:2] 156 64
.. .. ..$ : num [1, 1:2] 156 64
.. .. ..$ : num [1, 1:2] 156 64
.. .. ..$ : num [1, 1:2] 156 64
.. .. ..- attr(*, "dim")= int [1:3] 6 1 1
.. .. ..- attr(*, "dimnames")=List of 3
.. .. .. ..$ : chr [1:6] "Digit1" "Digit2" "Digit3" "Digit4" ...
.. .. .. ..$ : NULL
.. .. .. ..$ : NULL
.. ..- attr(*, "dim")= int [1:3] 4 1 1
.. ..- attr(*, "dimnames")=List of 3
.. .. ..$ : chr [1:4] "reference" "fixation" "probabilities" "lotteryValues"
.. .. ..$ : NULL
.. .. ..$ : NULL
..$ :List of 2
.. ..$ : chr [1, 1] "$5"
.. ..$ : chr[0 , 1]
.. ..- attr(*, "dim")= int [1:3] 2 1 1
.. ..- attr(*, "dimnames")=List of 3
.. .. ..$ : chr [1:2] "reference" "fixation"
.. .. ..$ : NULL
.. .. ..$ : NULL
..$ :List of 2
.. ..$ : num [1, 1] 150
.. ..$ : num [1, 1] 300
.. ..- attr(*, "dim")= int [1:3] 2 1 1
.. ..- attr(*, "dimnames")=List of 3
.. .. ..$ : chr [1:2] "width" "height"
.. .. ..$ : NULL
.. .. ..$ : NULL
..$ : num [1, 1] 10
..$ : num [1, 1:4] 0 0 1440 900
..$ : num [1, 1] 10
..$ : num [1, 1] 1
..$ : num [1, 1] 1
..- attr(*, "dim")= int [1:3] 11 1 1
..- attr(*, "dimnames")=List of 3
.. ..$ : chr [1:11] "fontName" "fontColor" "fontSize" "textDims" ...
.. ..$ : NULL
.. ..$ : NULL
$ :List of 2
..$ :List of 1
.. ..$ : chr [1, 1] "blue"
..$ :List of 1
.. ..$ : chr [1, 1] "red"
$ : num [1, 1] 280
$ : num [1, 1:280] 99 75 150 270 220 257 8 16 237 279 ...
$ : num [1:280, 1] 22.2 22.2 7.85 26.4 7.85 ...
$ : num [1:280, 1] 1 1 1 2 1 2 1 1 1 2 ...
$ : num [1:280, 1] 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 ...
$ : num [1:280, 1] 2 2 2 2 2 2 2 2 2 2 ...
$ : num [1:280, 1] 2 2 1 2 2 2 1 1 2 2 ...
$ : num [1:280, 1] 0 0 0 0 0 0 0 0 0 0 ...
$ : num [1:280, 1] 22.2 11.1 5.55 15.7 5.55 ...
$ : num [1, 1:280] 2 2 1 2 1 2 2 2 2 1 ...
$ : num [1, 1:280] 0.433 0.704 3.036 1.992 0.718 ...
- attr(*, "dim")= int [1:3] 15 1 1
- attr(*, "dimnames")=List of 3
..$ : chr [1:15] "observer" "date" "stimulus" "colorKey" ...
..$ : NULL
..$ : NULL
NULL
I would need to extract some variables from each of the objects [[i]]$Data, say var1 and var3, assign as an id the value stored in opsy, and get this into a dataframe that looks something like this:
id var1 var3
1 45 0.2
1 77 0.11
1 33 0.45
... .. ...
2 44 0.99
2 21 0.01
... .. ..
Any help would be much appreciated!
Max