Visualizes a matrix object plainly as heatmap. It provides a
plot
for matrices,assignColors
which assigns a specific color to
each value of a vector, andView the vignette on GitHub or after installing with
library("plot.matrix")
vignette("plot.matrix")
install.packages("plot.matrix")
Note that from github you install the current development version.
library("devtools")
install_github("sigbertklinke/plot.matrix")
plot.matrix
# you may need to adjust the margin sizes
library("plot.matrix")
par(mar=c(5.1, 4.1, 4.1, 4.1)) # default c(5.1, 4.1, 4.1, 2.1)
# numeric matrix
<- matrix(runif(50), nrow=10)
x plot(x)
plot(x, key=NULL)
plot(x, key=list(cex.axis=0.5, tick=FALSE))
plot(x, digits=3)
plot(x, breaks=c(0,1), digits=3, cex=0.6)
# logical matrix
<- matrix(runif(50)<0.5, nrow=10)
m plot(m)
plot(m, key=NULL, digits=1)
# character matrix
<- matrix(sample(letters[1:10], 50, replace=TRUE), nrow=10)
s plot(s)
plot(s, digits=10)
plot(s, digits=10, col=heat.colors(5), breaks=letters[1:5])
plot.loadings
# factor analysis
library("psych")
<- na.omit(bfi[,1:25]))
data #
<- factanal(data, 5)
fa1 plot(loadings(fa1))
#
<- fa(data, 5) # psych::fa
fa2 plot(loadings(fa2))
# principal component analysis
library("psych")
<- na.omit(bfi[,1:25]))
data #
<- princomp(data)
pa plot(loadings(pa), digits=NA) # no numbers
#
<- prcomp(data)
pa <- structure(pa$rotation, class="loadings")
ld plot(ld, digits=NA)
assignColors
# numeric vector
assignColors(runif(50))
# logical vector
assignColors(runif(50)<0.5)
# character vector
assignColors(sample(letters[1:10], 50, replace=TRUE))