-
-
Save adiamb/0727aa03209b2e495bcf859adffdf601 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ------------------------- ## | |
## 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