I'm trying o output the list names every time I run the function thru lapply
. I posted this question earlier that I posted earlier, and the answer provided by @Ananda Mahto worked fine until I upgraded my R
to version 3.2.0. It is no longer working and I get the following error message: Error in eval.parent(quote(names(X)))[substitute(x)[[3]]] : invalid subscript type 'symbol'
x <- ts(rnorm(40,5), start = c(1961, 1), frequency = 12)
y <- ts(rnorm(50,20), start = c(1971, 1), frequency = 12)
z <- ts(rnorm(50,39), start = c(1981, 1), frequency = 12)
a <- ts(rnorm(50,59), start = c(1991, 1), frequency = 12)
dat.list <- list(x=x,y=y,z=z,a=a)
abc <- function(x) {
r <- mean(x)
print(eval.parent(quote(names(X)))[substitute(x)[[3]]])
return(r)
}
forl <- lapply(dat.list, abc)
I'm not sure what the issues is, but I checked all the syntax in the new version of R
nothing has changed. Any help is greatly appreciated. I'm open to any new ideas as well.