Extract elements from a List

5

I have this list:

a <- list()
  a[[1]] <- matrix(c(1,2),nrow = 2)

How do I select element 2?

    
asked by anonymous 17.06.2016 / 01:35

1 answer

3
To access element 2 of the array in the list you first have to access the array - a[[1]] as it is the first element in the list - and then access the second element of the array - a[[1]]][[2]] or a[[1]][2] .

a[[1]][[2]]
[1] 2
    
17.06.2016 / 15:01