Hi,
Try either:
set.seed(28)
stats1<- as.data.frame(matrix(rnorm(5*10000),ncol=5))
pdf(paste("test",1,".pdf",sep=""))
par(mfrow=c(2,1))
lst1<- lapply(names(stats1),function(i) {hist(stats1[,i],100,col="lightblue",main=paste0("Histogram of ",i),xlab=i );qqnorm(stats1[,i])})
dev.off()
#or
pdf(paste("test1",1,".pdf",sep=""))
par(mfrow=c(2,1))
for(colName in names(stats1)){
hist(stats1[,colName],100,col="lightblue",xlab=colName,main=paste0("Histogram of ",colName))
qqnorm(stats1[,colName])
}
dev.off()
A.K.
I have a dataset with more than 50 columns, and I need to check
distribution for each variable. The idea was to plot histograms and qq
plots for each >of them and check if distribution is normal. I tried
something like this: