Hi all, I want to execute a loop of a program: for (u in Timeframemin:Timeframe){} Imagine that Timeframemin<-10 Timefram<-10000 Is it posible to execute the loop but only proving from 10 to 10000 but jumping 10 each time, for example, execute for 10,20,30.....to Timeframe. Other question is, when a program is "heavy" and has a lot of loops to execute (how can I know where loop is executing at the moment? There is some "print" or something to see in wich step of the loop is the program to see if the program is advancing? Many thanks in advance. [[alternative HTML version deleted]]
Hello, As for the first question, you can do something like Timeframemin<-10 Timefram<-10000 uFrame <- seq(Timeframemin, Timefram, by = 10) for(u in uFrame) {} As for the second question, the answer is yes, there is a print() function, which can be used for your purpose. Hope this helps, Rui Barradas Em 17-02-2013 18:53, Trying To learn again escreveu:> Hi all, > > I want to execute a loop of a program: > > for (u in Timeframemin:Timeframe){} > > Imagine that Timeframemin<-10 > Timefram<-10000 > > Is it posible to execute the loop but only proving from 10 to 10000 but > jumping 10 each time, for example, execute for 10,20,30.....to Timeframe. > > Other question is, when a program is "heavy" and has a lot of loops to > execute (how can I know where loop is executing at the moment? There is > some "print" or something to see in wich step of the loop is the program to > see if the program is advancing? > > Many thanks in advance. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >
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() ________________________________ From: eliza botto <eliza_botto at hotmail.com> To: "smartpink111 at yahoo.com" <smartpink111 at yahoo.com> Sent: Thursday, February 21, 2013 1:16 PM Subject: loop Dear Arun, i have a matrix called "res" of 124 rows and 12 columns. i want to draw curve of each column against the first column and want to save that file at a specific location in my computer. i used the following commands but they are not working names1<-1:123 ?b<-res[,1] mypath<-file.path("/R/SAVEHERE",paste("myplot_",names1,".jpg",sep="")) ?#change the file.path for(i in seq_along(mypath)){ ? lapply(seq_along(res),function(i) { ? jpeg(file=mypath[i]) ? matplot(res[[i]][,-1],type="l",col="grey") ? lines(b,lwd=2,col="black") ? dev.off() ? ?}) ?} i hope you can find the error thanks in advance elisa -------------- next part -------------- A non-text attachment was scrubbed... Name: myplot.pdf Type: application/pdf Size: 6444 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130221/ca45132e/attachment.pdf>