Hello, > Just looking at this, but it looks like ix doesn't exist: > sapply(1:length(inxlist), function(i) if(length(ix[[i]])) > fin1[ix[[i]], tkr + 1] <<- ua[i, tkr]) > > Trying to sort it out now.
Right, sorry. I've changed the name from 'ix' to 'inxlist' to make it more readable just before posting. And since the object 'ix' still existed in the R global environment it didn't throw an error... Your correction in the post that followed is what I meant. Correction (full loop, tested): for(tkr in 1:ncol(ua)){ x <- c(rd1[, tkr], as.Date("9999-12-31")) ix <- lapply(1:nr, function(i) which(x[i] <= dt1 & dt1 < x[i + 1])) sapply(1:length(ix), function(i) if(length(ix[[i]])) fin1[ix[[i]], tkr + 1] <<- ua[i, tkr]) } Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/index-instead-of-loop-tp4447672p4450186.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.