[R] Error in foo[[1:3]] : recursive indexing failed at level 2

arun smartpink111 at yahoo.com
Fri Jun 27 05:16:12 CEST 2014


You could use:
mapply(`==`, sapply(foo,`[`,1),1)
#    A     B     C 
# TRUE  TRUE FALSE 
A.K.





On Thursday, June 26, 2014 10:50 PM, ce <zadig_1 at excite.com> wrote:
Dear all,

I have a list of arrays :

foo<-list(A = c(1,3), B =c(1, 2), C = c(3, 1)) 

> foo
$A
[1] 1 3

$B
[1] 1 2

$C
[1] 3 1

I want to use all foo$A , foo$B and foo$C in a test :

> foo$A[1] == 1 
[1] TRUE
> foo[[1]][1] == 1 
[1] TRUE
> foo[[1:3]][1] == 1 
Error in foo[[1:3]] : recursive indexing failed at level 2


Is there a regular expression I can use ?

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list