Just for Fun: Using R to Create Targets
Aug 10, 2010 metroadminOK, not really science or soil-related, but a fun 5 minute use of R to make something you can use to improve your hand-eye coordination. Demonstrates several ways to use base graphics, user-defined functions, and calling functions from within other functions.
Implementation
# function to make the target f.target <- function(xy, s) { plot(0, 0, type='n', axes=FALSE, xlab='', ylab='', xlim=c(-1,1), ylim=c(-1,1)) grid(nx=50, ny=50, lty=1) abline(h=0, v=0, lwd=2) f.bullseye(list(x=0,y=0), s) f.bullseye(xy, s/2) } # function to make each bull's eye f.bullseye <- function(xy, s) { sapply(s, function(s_i) { points(xy, cex=s_i, lwd=2) } ) } # concentric circle sizes s <- c(2,8,16,24,32) # coordinates for bull's eye marks in each quadrant xy <- expand.grid(x=c(-0.66, 0.66), y=c(-0.66, 0.66)) # save 2x2 figure to PDF pdf(file='target_2x2.pdf', width=11, height=8.5) par(mfcol=c(2,2), mar=c(1,1,1,1)) for(i in 1:4) f.target(xy, s) dev.off() # save 2x1 figure to PDF pdf(file='target_2x1.pdf', width=8.5, height=11) par(mfcol=c(2,1), mar=c(1,1,1,1)) for(i in 1:2) f.target(xy, s) dev.off()