In an R list, why does indexing with [n]
instead of [[n]]
not return the nth element as non-R-programmers would expect?
lfile <- list('fileA.xls', 'file2.xls', 'fileY.xls')
ll <- list(list(1,2), list(3), list(4,5,6), list(7,8))
lv <- list(c(1,2), c(3), c(4,5,6), c(7,8))
> lfile[2]
[[1]]
[1] "file2.xls" # returns SUBLIST, not n'th ELEMENT
> lfile[[2]]
[1] "file2.xls" # returns ELEMENT