Skip to content
Prev 298793 / 398503 Next

Accessing named members of a list in an array

Your problem is that you are trying to
use `$` on an atomic vector rather than
a list:

 > a<- array(list(NULL),dim=c(2,2))
 > a[[1,1]] <- c(a=2,b=3)
 > a[[1,1]]$a
Error in a[[1, 1]]$a : $ operator is invalid for atomic vectors
 > a[[1,1]]
a b
2 3
 > a[[1,1]] <- list(a=2,b=3)
 > a[[1,1]]$a
[1] 2
 > a[[1,1]]
$a
[1] 2

$b
[1] 3


 From the description of the problem, perhaps
it would be easier to just have a 3-dimensional
array.

Pat
On 30/06/2012 14:35, mlell08 wrote: