Skip to content

Instantly share code, notes, and snippets.

@adiamb
Forked from tony91782/Automating.R
Created October 20, 2016 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adiamb/0727aa03209b2e495bcf859adffdf601 to your computer and use it in GitHub Desktop.
Save adiamb/0727aa03209b2e495bcf859adffdf601 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