[R] histograms and for loops

vioravis vioravis at gmail.com
Fri May 6 19:58:12 CEST 2011


This should work!!

for(i in 1:12){
xLabel <- paste("Graph",i) 
plotTitle <- paste("Graph",i,".jpg") 
jpeg(plotTitle)
print(hist(zNort1[,i], freq=FALSE, xlab=xLabel, col="blue",
main="Standardized Residuals Histogram", ylim=c(0,1), xlim=c(-3.0,3.0)),axes
= FALSE)
axis(1, col = "blue",col.axis = "blue")
axis(2, col= "red",col.axis = "red")
zNortmin<-min(zNort1[,1]) 
zNortmax<-max(zNort1[,1]) 
zNortmean<-mean(zNort1[,1]) 
zNortsd<-sd(zNort1[,1]) 
X1<-seq(-3.0, 3.0, by=.01) 
lines(X1, dnorm(X1, zNortmean, zNortsd) , col="black") 
dev.off()
} 
 

--
View this message in context: http://r.789695.n4.nabble.com/histograms-and-for-loops-tp3503648p3503758.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list