Description Usage Arguments Details Value Author(s) See Also Examples
This function creates a parallel coordinates plot (par-coords) for variables in a data, with each line representing a row.
1 2 3 4 5 | qparallel(vars = ~., data, scale = "range", names = break_str(vars),
na.action = na_impute, center = NULL, order = c("none", "MDS", "ANOVA",
"randomForest"), horizontal = FALSE, glyph = c("auto", "line",
"tick", "circle", "square", "triangle"), boxplot = FALSE, width = NULL,
jitter = NULL, amount = NULL, main = "", alpha = 1)
|
scale |
data standardizing method; possible values are |
names |
the variable labels to use in the plot (by default, they are the
variable names with non-alphanumeric characters replaced by line breaks
|
na.action |
the function to deal with missing values |
center |
the function to calculate where to center all the variables
(e.g. center at the medians), or a numeric value, or |
order |
methods to reorder the variables; see |
horizontal |
logical: direction of axes (horizontal or vertical) |
glyph |
draw complete segments for all observations or other types of glyphs to represent observations (the latter has speed gain in case of large data) |
boxplot |
logical: overlay boxplots on top of the par-coords plot or not |
width |
width of boxplots |
jitter |
|
amount |
jitter amount |
main |
title of plot |
alpha |
value for alpha-blending |
vars |
variables to show in the plot: a character vector of variable
names, or a numeric vector of column indices, or a two-sided formula like
|
data |
a mutaframe created by |
See common_key_press
for a series of common interactions.
Interactions specific to par-coords include: press R
to toggle the
min/max labels; the arrow keys are used to adjust the order of the variables
and flip the values of variables (like a mirror reflection) when the axes are
selected by the brush.
A par-coords plot
Yihui Xie
Other plots: qbar
; qboxplot
;
qdensity
; qhist
,
qspine
; qmval
;
qtime
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | library(cranvas)
### (1) flea data
data(flea, package = "tourr")
qflea <- qdata(flea, color = species)
## input variables
qparallel(~., data = qflea) # all variables
qparallel(~aede1 + aede2 + aede3, data = qflea) # 3 variables
qparallel(1:4, data = qflea) # first 4 variables
# input variables by names
qparallel(c("head", "aede1", "tars2", "aede3"), data = qflea)
## scaling
qparallel(~., data = qflea, main = "scale columns individually to [0, 1]")
qparallel(~., data = qflea, scale = "I", main = "unscaled data")
qparallel(~., data = qflea, scale = "sd", main = "mean 0 sd 1")
qparallel(~., data = qflea, scale = "global", main = "scale globally to [0, 1]")
## centering by median; add boxplots to assist understanding
qparallel(~., data = qflea, center = median, boxplot = TRUE)
## ordering
qparallel(~., data = qflea, order = "MDS") # similar variables together
# color is covariate, order by ANOVA p-value
qparallel(~., data = qflea, order = "ANOVA")
## we can use arrow keys to manually order the variables
## horizontal direction
qparallel(~., data = qflea, horizontal = TRUE)
## use glyphs instead of segments
qparallel(~., data = qflea, glyph = "tick")
qparallel(~., data = qflea, glyph = "circle")
## jittering
qparallel(~., data = qflea, jitter = "species")
## categorical linking
id <- link_cat(qflea, "species")
## now brush on plots; will see all rows in the same category brushed
## stop categorical linking
remove_link(qflea, id)
### (2) NRC rankings
qnrc <- qdata(nrcstat, color = RegCode)
## Overview: type, rankings
qparallel(13:10, data = qnrc, main = "Overview of Rankings", glyph = "tick",
horizontal = TRUE, boxplot = TRUE)
## link to a droplist (institution names)
record_selector(Institution, qnrc)
## TODO: we need keyboard interactions here instead of command line
brush(qnrc, "persistent") <- TRUE # begin persistent brushing
brush(qnrc, "color") <- "brown"
## select other objects now
brush(qnrc, "color") <- "green"
## again, select other objects
brush(qnrc, "color") <- "yellow"
brush(qnrc, "persistent") <- FALSE # transient brushing
qparallel(vars = 14:19, data = qnrc, main = "Research, Student Support, Diversity",
center = median, horizontal = TRUE, glyph = "tick")
### (3) Missing values are imputed by 20% below the mean
df <- as.data.frame(replicate(5, sample(c(rep(NA, 10), rnorm(100)))))
mf <- qdata(df)
qparallel(~., data = mf)
## see this by missing value plot
qmval(~., data = mf)
### (4) alpha transparency
if (require("animation")) {
data(pollen, package = "animation")
qpollen <- qdata(pollen)
qparallel(~., data = qpollen)
# hold the minus key (-) till the plot is semi-transparent
}
### (5) pressure test
test.mat <- qdata(matrix(rnorm(3e+05 * 10), ncol = 10))
qparallel(~., data = test.mat)
## for large data, short ticks are automatically used instead of segments
cranvas_off()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.