I have 4 data frames which contain a date column, a price column and a return column.
data.1:
Date Price Return
2009-01-02 100 0.2
2009-01-03 110 0.1
etc.
data.2:
Date Price Return
2009-02-02 60 0.15
2009-02-03 50 -0.1
etc.
I would like to set up a loop and apply the function density() to each data frame, returning the density values for the returns.
I through about creating a list, setting up a loop and using lapply() to do this, so
> ff <- list(data.1, data.2, data.3, data.4)
> for(i in 1:length(ff){
density[[i]] <- lapply(ff, density(ff[[i]]$Return))}
but this obviously doesn't work. Could somebody offer me some help?
Thanks in advance - Dani
See Question&Answers more detail:os