Recursive indexing failed

An example where recursive indexing failed error is not clear mydf = list(a=c(1,2,3,5,7,11,13), b=c(1,3,5,7,9,11,13), c=c(2,4,6,8,10,12,14)) Indexing of mydf is done by list indexing syntax mydf$a ## [1] 1 2 3 5 7 11 13 mydf[['b']] ## [1] 1 3 5 7 9 11 13 However, inside an outer function, it does not work k = names(mydf) myfunc = function(x,y) { return(length(mydf[[x]]) + length(mydf[[y]])) } tryCatch(expr = { outer(k,k,myfunc) }, error= function(e) { print(e) }) ## <simpleError in mydf[[x]]: recursive indexing failed at level 2 ## > Similarly with sapply

Continue reading

Author's picture

Trang Tran


Student

USA