I would like the make the bit that uses lapply() more elegant…(i.e. a one liner would be good) rather than having to set up a function before. i.e. is there a standard function in which i can use [,c(1:4)] or something similar as an argument…
so to make a reproducible example…
x <- xts(matrix(rnorm(500*8),ncol=8),Sys.Date()-500:1)
x.m <- split(x,'months')
The following basically only takes the first 4 columns for each element of the list created from the split and thus i have to make a function that does this but i would like it to be more elegant somehow…
ff <- function(xts.obj){xts.obj[,c(1:4)]}
g <- lapply(x.m, ff)
Thanks
[is a functionSo, you can just use that. Either of these will do it.