[R] extract element from list by rownames
Alfredo Alessandrini
alfreale74 at gmail.com
Tue Apr 12 16:16:24 CEST 2011
Hi,
I've a list of list.
I want to extract an element by the rownames.
I can extract it by:
data[[1]][[1]][[4]][1]
But I want to exctract it by a command like this:
data[[1]][["B0"]][["smac"]][["cont"]][1]
It's possible?
Thanks,
Alfredo
> str(data)
List of 1
$ :List of 4
..$ :List of 4
.. ..$ : num [1, 1:3] 0.4 0.458 0.5
.. ..$ : num [1:41, 1] 0.4 0.403 0.405 0.407 0.41 ...
.. ..$ : num [1:41, 1] 0.000128 0.000328 0.000528 0.000728 0.000992 ...
.. ..$ :List of 1
.. .. ..$ : num [1:49, 1] 0 0 -0.00626 0.99832 0 ...
.. .. ..- attr(*, "dim")= int [1:3] 1 1 1
.. .. ..- attr(*, "dimnames")=List of 3
.. .. .. ..$ : chr "cont"
.. .. .. ..$ : NULL
.. .. .. ..$ : NULL
.. ..- attr(*, "dim")= int [1:3] 4 1 1
.. ..- attr(*, "dimnames")=List of 3
.. .. ..$ : chr [1:4] "begin.mode.end" "lambda" "sensi" "smac"
.. .. ..$ : NULL
.. .. ..$ : NULL
..$ :List of 4
.. ..$ : num [1, 1:3] 0.58 0.67 0.782
.. ..$ : num [1:82, 1] 0.58 0.583 0.585 0.588 0.59 ...
.. ..$ : num [1:82, 1] 0.0017 0.00168 0.00165 0.00162 0.0016 ...
.. ..$ :List of 1
.. .. ..$ : num [1:49, 1] -0.00597 0.71045 -0.05844 0.99187 -0.00807 ...
.. .. ..- attr(*, "dim")= int [1:3] 1 1 1
.. .. ..- attr(*, "dimnames")=List of 3
.. .. .. ..$ : chr "cont"
.. .. .. ..$ : NULL
.. .. .. ..$ : NULL
.. ..- attr(*, "dim")= int [1:3] 4 1 1
.. ..- attr(*, "dimnames")=List of 3
.. .. ..$ : chr [1:4] "begin.mode.end" "lambda" "sensi" "smac"
.. .. ..$ : NULL
.. .. ..$ : NULL
..$ :List of 4
.. ..$ : num [1, 1:3] 0.7 0.82 1.03
.. ..$ : num [1:133, 1] 0.7 0.703 0.705 0.708 0.71 ...
.. ..$ : num [1:133, 1] 0.0007 0.000775 0.00085 0.000925 0.001 ...
.. ..$ :List of 1
.. .. ..$ : num [1:49, 1] -0.030584 0.559164 -0.000269 0.995624 -0.006616 ...
.. .. ..- attr(*, "dim")= int [1:3] 1 1 1
.. .. ..- attr(*, "dimnames")=List of 3
.. .. .. ..$ : chr "cont"
.. .. .. ..$ : NULL
.. .. .. ..$ : NULL
.. ..- attr(*, "dim")= int [1:3] 4 1 1
.. ..- attr(*, "dimnames")=List of 3
.. .. ..$ : chr [1:4] "begin.mode.end" "lambda" "sensi" "smac"
.. .. ..$ : NULL
.. .. ..$ : NULL
..$ :List of 4
.. ..$ : num [1, 1:3] 1.45 1.64 1.8
.. ..$ : num [1:141, 1] 1.45 1.45 1.46 1.46 1.46 ...
.. ..$ : num [1:141, 1] 0.001 0.001 0.001 0.001 0.001 ...
.. ..$ :List of 1
.. .. ..$ : num [1:49, 1] -0.00547 0.65798 0 0 0 ...
.. .. ..- attr(*, "dim")= int [1:3] 1 1 1
.. .. ..- attr(*, "dimnames")=List of 3
.. .. .. ..$ : chr "cont"
.. .. .. ..$ : NULL
.. .. .. ..$ : NULL
.. ..- attr(*, "dim")= int [1:3] 4 1 1
.. ..- attr(*, "dimnames")=List of 3
.. .. ..$ : chr [1:4] "begin.mode.end" "lambda" "sensi" "smac"
.. .. ..$ : NULL
.. .. ..$ : NULL
..- attr(*, "dim")= int [1:3] 4 1 1
..- attr(*, "dimnames")=List of 3
.. ..$ : chr [1:4] "B0" "B2" "B3" "MIR"
.. ..$ : NULL
.. ..$ : NULL
>
More information about the R-help
mailing list