| multi.hist {psych} | R Documentation |
Given a matrix or data.frame, produce histograms for each variable in a "matrix" form.
multi.hist(x)
x |
matrix or data.frame |
William Revelle
Northwestern University
Evanston, Illinois
revelle@northwestern.edu
http://personality-project.org/revelle.html
##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function(x) {nvar <- dim(x)[2] #number of variables
nsize=trunc(sqrt(nvar))+1 #size of graphic
old.par <- par(no.readonly = TRUE) # all par settings which can be changed
par(mfrow=c(nsize,nsize)) #set new graphic parameters
for (i in 1:nvar) {
name=names(x)[i] #get the names for the variables
hist(x[,i],main=name,xlab=name) } #draw the histograms for each variable
on.exit(par(old.par)) #set the graphic parameters back to the original
}