..... <- function(prompt="\n[hit enter to continue]: ") { cat(prompt, sep='') invisible(readline()) } demo.me <- function(title, expr.str) { cat(title, "\n", rep('=', nchar(title)), "\n", sep='') cat('R> ', expr.str, sep='') .....("\n[Enter to execute]: ") cat(eval(parse(text=expr.str)), sep=' ') .....("\n\n") } # Set default margins for plotting (only slightly different from the default) par(mar=c(5, 5, 4, 2)) Ns = 1:7 Squares = Ns^2 demo.me("A range", 'Ns = 1:7') demo.me("Squares of range", 'Squares = Ns^2') demo.me( "Plot squares of range", 'plot(Squares)' ) demo.me( "Nicer red N-sqared sized circles", 'plot(Squares, pch=20, col="red", cex=Ns*5)' ) demo.me( "Add title, labels, fix y-axis-labels to horizontal", 'plot(Squares, pch=20, col="red", cex=Ns*5, main="nirvana", cex.main=3, las=1, xlab="N", ylab="N^2", cex.lab=1.25, font.lab=4)' ) demo.me( "Add a grid", 'grid(col="#888888")' ) demo.me( "Add blue bulls-eye", 'points(Squares, pch=19, col="blue", cex=Ns)' ) demo.me( "Add black circles around circles", 'points(Squares, pch=21, col="black", cex=Ns*4)' ) demo.me( "Add orange dashed lines connecting the centers", 'lines(Squares, col="orange", lwd=4, lty=3)' ) demo.me( "Wow!!!", 'text(2.5, 30, "Wow!!!", col="#cc0044", cex=2.5, font=4)' )