Ivo Shterev wrote:
>
>
> I have a question about list indexing. Lets say we have a list of 3 lists,
> each containing 3 different type elements:
>
>
(Details of your nice example code removed)
a=replicate(3, list(list(c(1,1,1), diag(3), c(2,2,2))))
str(a) # I prefer this to print(a) because it shows the structure better
# in steps
b = lapply(a,function(x){
# print(str(a)) # put this here to know what you are doing
x[2:3]
}
)
#... mmm, not yet what you wanted. Another try
b[1:2]
# I leave it as a easy exercise to jam this into a one-liner
---
Dieter
--
View this message in context:
http://www.nabble.com/List-subsetting-tp24194764p24198222.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@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.