Hi, I have the following problem- I want to access a list whose elements are imp1, imp2, imp3 etc I tried theusing the paste comand in a for loop see the last for loop below. But I keep calling it df but df = imp1 (for the first run). Any ideas on how I can access the elements of the list?
Isaac require(Amelia) library(Amelia) data.use <- read.csv("multiplecarol.CSV", header=T) names(data.use) = c("year", "dischargex1", "y", "pressurex2" , "windx3") ts <- c (c(1:12), c(1:12), c(1:12), c(1:12), c(1:12), c(1:12), c(1:12), c(1:6) ) length(ts) data.use = cbind(ts, data.use) #a.out2 <- amelia(data.use, m = 1000, idvars = "year") n.times = 100 a.out.time <- amelia(data.use, m = n.times, ts="ts", idvars="year", polytime=2) constant.col = dischargex1.col = pressurex2.col = windx3.col = rep(0,n.times) for (i in 1: n.times) { x = c("imp",i) df = paste(x, collapse = "") data1 = a.out.time[[1]]$df attach(data1) y = as.numeric(y) dischargex1 = as.numeric(dischargex1) pressurex2 = as.numeric(pressurex2) windx3 = as.numeric(windx3) multi.regress = lm(y~ dischargex1 + pressurex2 + windx3) constant.col[i] = as.numeric(multi.regress[[1]][1]) dischargex1.col[i] = as.numeric(multi.regress[[1]][2]) pressurex2.col[i] = as.numeric(multi.regress[[1]][3]) windx3.col[i] = as.numeric(multi.regress[[1]][4]) } -- Thanks, Jim. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.