Description Usage Arguments Examples
Interactive Conditional Density Plot
1 | fdPlotConditionalDensity(x, y, title = NULL, showlegend = TRUE, ...)
|
x |
a numeric vector |
y |
a "factor" interpreted to be the dependenty variable |
title |
optional title for the plot |
showlegend |
boolean indicating if a legend should be displayed. |
... |
additional arguments to pass to |
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 | library(flightdeck)
# Example 1: NASA space shuttle o-ring failures
fail <- factor(c(2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1,
1, 2, 1, 1, 1, 1, 1),
levels = 1:2, labels = c("no", "yes")
)
temperature <- c(
53, 57, 58, 63, 66, 67, 67, 67, 68, 69, 70, 70,
70, 70, 72, 73, 75, 75, 76, 76, 78, 79, 81
)
# Conditional Density Plot
# cdplot(fail ~ temperature)
if (interactive()){
fdPlotConditionalDensity(temperature, fail)
}
# Example 2: Iris
if (interactive()){
fdPlotConditionalDensity(iris$Petal.Length, iris$Species, xlab = 'Petal.Length')
}
# Example 3A: Panel of Plots
dat <- iris
dat$Species <- as.factor(dat$Species)
eachPlotWidth = 6
numericColumns <- names(dat)[sapply(dat, is.numeric)]
# Facets in a Single Panel
cdPlots <- lapply(numericColumns, function(x){
plt <- fdPlotConditionalDensity(x = dat[[x]], y = dat[['Species']],
xlab = x, showlegend = FALSE
)
fdColumn(plt, width = eachPlotWidth)
})
fdRow(cdPlots) %>%
fdPreviewBoard(title = 'Conditional Density Plots', wrap = 'box')
# Tabbed Panel
cdPlots <- lapply(numericColumns, function(x){
plt <- fdPlotConditionalDensity(x = dat[[x]], y = dat[['Species']],
xlab = x, showlegend = FALSE
)
fdTabPanel(plt, title = x)
})
fdTabsetPanel(selected = makeHtmlId('Sepal.Length'), .list = cdPlots) %>%
fdColumn(width = 12) %>%
fdPreview(wrap = 'row')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.