I have list of data with varying list length:
[[1]]
[1] "2009" "2010" "2011" "2012"
[[2]]
[1] "2010" "2011" "2012" "2013"
[[3]]
[1] "2008" "2009" "2010" "2011" "2012"
[[4]]
[1] "2011" "2012"
I would like to get one column data.frame like this:
2009
2010
2011
2012
2010
2011
....
I went on doing this unsuccessfully:
# transpose list of years
YearsDf <- lapply(GetYears, data.frame)
Remove colnames (since the list of dataframes gave some weird column names):
YearsOk <- lapply(YearsDf, function(x) "colnames<-"(x, NULL))
All this comes to:
[[1]]
NA
1 2009
2 2010
3 2011
4 2012
[[2]]
NA
1 2010
2 2011
3 2012
4 2013
......
Now just bind and get data.frame. This gave NA's
ldply(YearsOk, data.frame)
How I get to the data.frame of one column?