I have four timeseries and what I want to do is to get the logarithm from each one in a for-loop. I could do it individually but there's no fun in that.
So I got:
db$M1 <- c(1,2,3,4,5)
db$M2 <- c(1,2,3,4,5)
db$M3 <- c(1,2,3,4,5)
db$M4 <- c(1,2,3,4,5)
M1 <- ts(db$M1, start = c(1995, 12), frequency = 12)
M2 <- ts(db$M2, start = c(1995, 12), frequency = 12)
M3 <- ts(db$M3, start = c(1995, 12), frequency = 12)
M4 <- ts(db$M4, start = c(1995, 12), frequency = 12)
and what i've tried is:
AM <- list(M1, M2, M3, M4)
for(x in AM) {
assign(paste0("log_", x), log(x))
}
Of course that doesn't work, also tried parse() with no luck
Bonus points if you can help me loop the M# <- ts(...)
Thanks