Trying to use R to build an interactive "slide show", to be displayed on a projector. The purpose of the presentation is to show how one could construct a simple graph using R. It is meant as a general overview rather than as detailed instruction. For example, something like the following sequence of commands. At lecture time, I want the interpreter to read these commands one at a time from a file, display and execute the command, (or two or three commands) and then wait for another prompt. pale.yellow="#ffff99" par(bg=pale.yellow) plot(c(0,2*pi),c(-1,1),type="n",ylab="",yaxt="n") mirror<-function(t) { c(t,rev(2*max(t)-t)) } z<-log(1:1000)/log(1000) zz<-z*pi/2 zzz<-mirror(mirror(zz)) polygon(zzz,sin(25*zzz)*sin(zzz),border="blue") polygon(zzz,sin(5*zzz)*sin(zzz),border="green") polygon(zzz,sin(zzz),lwd=2) points(zzz,rep(0,length(zzz)),col="red",pch="|") Wrapping the following around each command works, sort of : a<-expression(<command>) x<-readline(a) eval(a) However, this doesn't work properly for the function definition, and it gets very clumsy to display two or three lines as a block and then evaluate. Any help would be much appreciated. <>=<>=<>=<>=<>=<>=<>=<>=<>=<>=<> George Heine, PhD Mathematical Analyst National IRM Center U.S. Bureau of Land Management voice (303) 236-0099 fax (303) 236-1974 cell (303) 905-5382 pager gheine at my2way.com <>=<>=<>=<>=<>=<>=<>=<>=<>=<>=<>
One possible strategy: see ?readLines Write a text file with your R commands. Then write a little function that opens a connection to the file and runs a loop to: 1)read a line from your file via readLines 2) cat() the line on your terminal 3) prompt via readline to execute it. You'll have to get a little fancy to check for expressions that span several lines and check for the end of file, but this should work, I think. Cheers, -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of > George_Heine at blm.gov > Sent: Tuesday, March 29, 2005 12:54 PM > To: R-Help > Subject: [R] slide show with R > > > > > > Trying to use R to build an interactive "slide show", to be > displayed on a > projector. The purpose of the presentation is to show how one could > construct a simple graph using R. It is meant as a general > overview rather > than as detailed instruction. > > For example, something like the following sequence of commands. At > lecture time, I want the interpreter to read these commands > one at a time > from a file, display and execute the command, (or two or > three commands) > and then wait for another prompt. > > pale.yellow="#ffff99" > par(bg=pale.yellow) > plot(c(0,2*pi),c(-1,1),type="n",ylab="",yaxt="n") > mirror<-function(t) { c(t,rev(2*max(t)-t)) } > z<-log(1:1000)/log(1000) > zz<-z*pi/2 > zzz<-mirror(mirror(zz)) > polygon(zzz,sin(25*zzz)*sin(zzz),border="blue") > polygon(zzz,sin(5*zzz)*sin(zzz),border="green") > polygon(zzz,sin(zzz),lwd=2) > points(zzz,rep(0,length(zzz)),col="red",pch="|") > > > Wrapping the following around each command works, sort of : > > a<-expression(<command>) > x<-readline(a) > eval(a) > > However, this doesn't work properly for the function > definition, and it > gets very clumsy to display two or three lines as a block and then > evaluate. > > Any help would be much appreciated. > > > <>=<>=<>=<>=<>=<>=<>=<>=<>=<>=<> > George Heine, PhD > Mathematical Analyst > National IRM Center > U.S. Bureau of Land Management > voice (303) 236-0099 > fax (303) 236-1974 > cell (303) 905-5382 > pager gheine at my2way.com > <>=<>=<>=<>=<>=<>=<>=<>=<>=<>=<> > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >
Oops, I should have said that you can execute the text line via the construction: eval(parse(text=textline)) -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of > George_Heine at blm.gov > Sent: Tuesday, March 29, 2005 12:54 PM > To: R-Help > Subject: [R] slide show with R > > > > > > Trying to use R to build an interactive "slide show", to be > displayed on a > projector. The purpose of the presentation is to show how one could > construct a simple graph using R. It is meant as a general > overview rather > than as detailed instruction. > > For example, something like the following sequence of commands. At > lecture time, I want the interpreter to read these commands > one at a time > from a file, display and execute the command, (or two or > three commands) > and then wait for another prompt. > > pale.yellow="#ffff99" > par(bg=pale.yellow) > plot(c(0,2*pi),c(-1,1),type="n",ylab="",yaxt="n") > mirror<-function(t) { c(t,rev(2*max(t)-t)) } > z<-log(1:1000)/log(1000) > zz<-z*pi/2 > zzz<-mirror(mirror(zz)) > polygon(zzz,sin(25*zzz)*sin(zzz),border="blue") > polygon(zzz,sin(5*zzz)*sin(zzz),border="green") > polygon(zzz,sin(zzz),lwd=2) > points(zzz,rep(0,length(zzz)),col="red",pch="|") > > > Wrapping the following around each command works, sort of : > > a<-expression(<command>) > x<-readline(a) > eval(a) > > However, this doesn't work properly for the function > definition, and it > gets very clumsy to display two or three lines as a block and then > evaluate. > > Any help would be much appreciated. > > > <>=<>=<>=<>=<>=<>=<>=<>=<>=<>=<> > George Heine, PhD > Mathematical Analyst > National IRM Center > U.S. Bureau of Land Management > voice (303) 236-0099 > fax (303) 236-1974 > cell (303) 905-5382 > pager gheine at my2way.com > <>=<>=<>=<>=<>=<>=<>=<>=<>=<>=<> > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >
Seems like emacs-ess would do the trick. You can read in the entire file - formatted or spaced as appropriate - execute one line or several at a time and see the results in real time. Obviously less a "slide show" than an R session, but that seems to be what you want. A more "canned" slide show like approach might be something like Sweave/Prosper. This is considerably more work, loses the ability to interact with the interpreter -- but does achieve a very slick slideshow sort of look. On Tue, 2005-03-29 at 14:54, George_Heine at blm.gov wrote:> > > Trying to use R to build an interactive "slide show", to be displayed on a > projector. The purpose of the presentation is to show how one could > construct a simple graph using R. It is meant as a general overview rather > than as detailed instruction. > > For example, something like the following sequence of commands. At > lecture time, I want the interpreter to read these commands one at a time > from a file, display and execute the command, (or two or three commands) > and then wait for another prompt. > > pale.yellow="#ffff99" > par(bg=pale.yellow) > plot(c(0,2*pi),c(-1,1),type="n",ylab="",yaxt="n") > mirror<-function(t) { c(t,rev(2*max(t)-t)) } > z<-log(1:1000)/log(1000) > zz<-z*pi/2 > zzz<-mirror(mirror(zz)) > polygon(zzz,sin(25*zzz)*sin(zzz),border="blue") > polygon(zzz,sin(5*zzz)*sin(zzz),border="green") > polygon(zzz,sin(zzz),lwd=2) > points(zzz,rep(0,length(zzz)),col="red",pch="|") > > > Wrapping the following around each command works, sort of : > > a<-expression(<command>) > x<-readline(a) > eval(a) > > However, this doesn't work properly for the function definition, and it > gets very clumsy to display two or three lines as a block and then > evaluate. > > Any help would be much appreciated. > > > <>=<>=<>=<>=<>=<>=<>=<>=<>=<>=<> > George Heine, PhD > Mathematical Analyst > National IRM Center > U.S. Bureau of Land Management > voice (303) 236-0099 > fax (303) 236-1974 > cell (303) 905-5382 > pager gheine at my2way.com > <>=<>=<>=<>=<>=<>=<>=<>=<>=<>=<> > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > >
Another approach is to put your commands below into a text file. Add a line like: tmp <- readline('Press Enter to Continue:') everywhere you want to pause. Then do: source('path/to/text/file', echo=T) it will print out the commands and execute them, but everytime it gets to the tmp <- ... line it will pause and wait for you to press enter before continuing on. you can discuss the lines that have just been executed and the current plot, then press enter for the next chunk. hope this helps, Greg Snow, Ph.D. Statistical Data Center greg.snow at ihc.com (801) 408-8111>>> <George_Heine at blm.gov> 03/29/05 01:54PM >>>Trying to use R to build an interactive "slide show", to be displayed on a projector. The purpose of the presentation is to show how one could construct a simple graph using R. It is meant as a general overview rather than as detailed instruction. For example, something like the following sequence of commands. At lecture time, I want the interpreter to read these commands one at a time from a file, display and execute the command, (or two or three commands) and then wait for another prompt. pale.yellow="#ffff99" par(bg=pale.yellow) plot(c(0,2*pi),c(-1,1),type="n",ylab="",yaxt="n") mirror<-function(t) { c(t,rev(2*max(t)-t)) } z<-log(1:1000)/log(1000) zz<-z*pi/2 zzz<-mirror(mirror(zz)) polygon(zzz,sin(25*zzz)*sin(zzz),border="blue") polygon(zzz,sin(5*zzz)*sin(zzz),border="green") polygon(zzz,sin(zzz),lwd=2) points(zzz,rep(0,length(zzz)),col="red",pch="|") Wrapping the following around each command works, sort of : a<-expression(<command>) x<-readline(a) eval(a) However, this doesn't work properly for the function definition, and it gets very clumsy to display two or three lines as a block and then evaluate. Any help would be much appreciated. <>=<>=<>=<>=<>=<>=<>=<>=<>=<>=<> George Heine, PhD Mathematical Analyst National IRM Center U.S. Bureau of Land Management voice (303) 236-0099 fax (303) 236-1974 cell (303) 905-5382 pager gheine at my2way.com <>=<>=<>=<>=<>=<>=<>=<>=<>=<>=<> ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html