Making a vector from list elements in R
list, r
Solution
This would be easier if you give a minimal example object. In general, you can not index lists with vectors like `[[1:1000]]`. I would use the `plyr` functions. This should do it (although I haven't tested it):
require("plyr")
laply(bootfits$fvboot,function(l) l[i,j])
If you are not familiar with `plyr`: I always found Hadley Wickham's article 'The split-apply-combine strategy for data analysis' very useful.
Problem
I've got a list of lists of bootstrap statistics from a function that I wrote in R. The main list has the 1000 bootstrap iterations. Each element within the list is itself a list of three things, including fitted values for each of the four variables ("fvboot" -- a 501x4 matrix). I want to make a vector of the values for each position on the grid of x values, from 1:501, and for each variable, from 1:4. For example, for the ith point on the xgrid of the jth variable, I want to make a vector like the following: ``` vec = bootfits$fvboot[[1:1000]][i,j] ``` but when I do this, I get: ``` recursive indexing failed at level 2 ``` googling around, i think I understand why R is doing this. but I'm not getting an answer for how I can get the ijth element of each fvboot matrix into a 1000x1 vector. help would be much appreciated.