DescTools (version 0.99.15)

PlotWeb: Plot a Web of Connected Points

Description

This plot can be used to graphically display a correlation matrix by using the linewidth between the nodes in proportion to the correlation of two variables. It will place the elements homogenously around a circle and draw connecting lines between the points.

Usage

PlotWeb(m, col = c("red", "blue"), lty = par("lty"), args.legend=NULL, 
        pch = 21, pt.cex = 2, pt.col = "black", pt.bg = "darkgrey", ...)

Arguments

m
a matrix with numeric values
col
the color for the connecting lines
lty
the line type for the connecting lines
args.legend
list of additional arguments to be passed to the legend function. Use args.legend = NA if no legend should be added.
pch
the plotting symbols appearing in the plot, as a non-negative numeric vector (see points, but unlike there negative values are omitted) or a vector of 1-character strings, or one multi-character string.
pt.cex
expansion factor(s) for the points.
pt.col
the foreground color for the points, corresponding to its argument col.
pt.bg
the background color for the points, corresponding to its argument bg.
...
dots are passed to plot.

Value

  • A list of x and y coordinates, giving the coordinates of all the points drawn, useful for adding to the graph.

See Also

PlotCorr

Examples

Run this code
m <- cor(d.pizza[, which(sapply(d.pizza, IsNumeric, na.rm=TRUE))[-c(1:2)]], 
         use="pairwise.complete.obs")
PlotWeb(m=m, col=c("red","blue"), main="Pizza Correlation")


# let's describe only the significant corrs and start with a dataset
d.m <- d.pizza[, which(sapply(d.pizza, IsNumeric, na.rm=TRUE))[-c(1:2)]]

# get the correlation matrix
m <- cor(d.m, use="pairwise.complete.obs")

# let's get rid of all non significant correlations
ctest <- PairApply(d.m,  function(x, y) cor.test(x, y)$p.value, symmetric=TRUE) 

# ok, got all the p-values, now replace > 0.05 with NAs
m[ctest > 0.05] <- NA
# How does that look like now?
noquote(Format(m, na.form = ". ", leading="drop", digits=3, align = "right"))

PlotWeb(m)

Run the code above in your browser using DataLab