Re: [R] Accessing named members of a list in an array

2012-06-30 Thread Patrick Burns
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,

Re: [R] Accessing named members of a list in an array

2012-06-30 Thread Peter Ehlers
On 2012-06-30 09:04, David Winsemius wrote: On Jun 30, 2012, at 9:35 AM, mlell08 wrote: Dear List, I've created a two-dimensional array which shall contain a value and its error, respectively. These two values are concatenated in al list and bear the names "sl" and "sl_err" But I can't adres

Re: [R] Accessing named members of a list in an array

2012-06-30 Thread arun
Hi, You can use these as well to access named members. > a[1] [[1]] a b 2 3  >a[1][[1]][1] a 2 > a[[1,1]][1] a 2 >a[[1,1]][2] b 3   >identical(a[[1,1]]["a"],a[[1,1]][1],a[1][[1]][1]) [1] TRUE > a[[1,1]][["a"]] [1] 2 > a[[1,1]][["b"]] [1] 3 or, > a[[c(1,2)]] [1] 3  >a[[c(1,1)]] [1]

Re: [R] Accessing named members of a list in an array

2012-06-30 Thread David Winsemius
On Jun 30, 2012, at 9:35 AM, mlell08 wrote: Dear List, I've created a two-dimensional array which shall contain a value and its error, respectively. These two values are concatenated in al list and bear the names "sl" and "sl_err" But I can't adress them using the $-notation. a<- array