Hello, I'm pretty new to R. Basically, how do I speed up the for loop below. Or better yet, get rid of the for loop all together.
objective: plot two data sets column against column by index. These data sets have alot NA's. Some columns are all NA's. I need the plots to overlay. I don't like the plots in matplot(). Needs to be much faster than the code below... #simple sample data.. my data sets have 61 rows and over 11k columns each. x = matrix(1:4,2,2) y = matrix(4:1,2,2) y[2,2] = NA y[1,1] = NA #calc'd here to save time on plotting xlim.v = c(min(x, na.rm = TRUE),max(x,na.rm = TRUE)) ylim.v = c(min(y, na.rm = TRUE),max(y,na.rm = TRUE)) for(i in 1:ncol(x)){ xy = na.omit(cbind(x[,i],y[,i])) if(length(dim(xy)[1]) > 0){ plot(xy[,1],xy[,2],xlim = xlim.v,ylim= ylim.v); par(new=T); } } Thanks! [[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.