Skip to content
Prev 318061 / 398506 Next

loop

Hi,

Try this:
You can save it as either individual jpeg files or as a single pdf document containing all the figures.
set.seed(54)
res<- matrix(sample(20:60,25,replace=TRUE),ncol=5)
res1<- res[,-1]
b<- res[,1]
#jpeg
?mypath<- file.path("/home/arunksa111/Trial", paste("myplot_",names1,".jpg",sep=""))

for(i in seq_along(mypath)){
lapply(seq_len(ncol(res1)),function(i){
jpeg(file=mypath[i]) 
?matplot(res1[,i],type="l",col="grey")
?lines(b,lwd=2,col="black")
?dev.off()
?})
?}

#pdf
mypath1<- file.path("/home/arunksa111/Trial", "myplot.pdf")
pdf(file=mypath1) 
lapply(seq_len(ncol(res1)),function(i){
?matplot(res1[,i],type="l",col="grey")
?lines(b,lwd=2,col="black")
?})
?dev.off()