Skip to content

Instantly share code, notes, and snippets.

@tony91782
Created May 1, 2011 19:33
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tony91782/950784 to your computer and use it in GitHub Desktop.
Save tony91782/950784 to your computer and use it in GitHub Desktop.
## ------------------------- ##
## An Example of ##
## Automating Plot Output ##
## ------------------------- ##
names = LETTERS[1:26] ## Gives a sequence of the letters of the alphabet
beta1 = rnorm(26, 5, 2) ## A vector of slopes (one for each letter)
beta0 = 10 ## A common intercept
for(i in 1:26){
x = rnorm(500, 105, 10)
y = beta0 + beta1[i]*x + 15*rnorm(500)
mypath <- file.path("C:","R","SAVEHERE",paste("myplot_", names[i], ".jpg", sep = ""))
jpg(file=mypath)
mytitle = paste("my title is", names[i])
plot(x,y, main = mytitle)
dev.off()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment