I have 11 lists of different length, imported into R as p1,p2,p3,...,p11. Now I want to get the rollmean (library TTR) from all lists and name the result p1y,p2y,...,p11y.
This seems to be the job for a loop, but I read that this is often not good practice in R. I tried something (foolish) like
sample=10
for (i in 1:11){
paste("p",i,"y",sep="")<-rollmean(paste("p",i,sep=""),sample)
}
which does not work. I also tried to use it in combination with assign(), but as I understand assign can only take a variable and a single value.
As always it strikes me that I am missing some fundamental function of R.
rollmeancan operate by column. We wouldn't have to guess if you had you provided sample data. Also,rollmeanis in zoo; the TTR function isrunMean.