View source: R/stat-debug-panel.R
stat_debug_panel | R Documentation |
stat_debug
reports all distinct values in group
and PANEL
, and nrow
, ncol
and the names of the columns
or variables, and the class of x and y for each panel in a ggplot as passed
to the compute_panel
function in the ggproto
object.
stat_debug_panel(
mapping = NULL,
data = NULL,
geom = "null",
summary.fun = "head",
summary.fun.args = list(),
geom.summary.fun = NULL,
geom.summary.fun.args = list(),
position = "identity",
na.rm = FALSE,
show.legend = FALSE,
inherit.aes = TRUE,
...
)
mapping |
The aesthetic mapping, usually constructed with
|
data |
A layer specific dataset - only needed if you want to override the plot defaults. |
geom |
The geometric object to use display the data |
summary.fun, geom.summary.fun |
A function used to print the |
summary.fun.args, geom.summary.fun.args |
A named list. |
position |
The position adjustment to use for overlapping points on this layer |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
... |
other arguments passed on to |
This stat is meant to be used for the side-effect of printing to the
console the data
object received as input by the
compute_panel()
function, or a summary of it. This is the same as
for any other statistics passed the same arguments (including defaults that
may need to be overridden if they differ).
In principle any geom can be passed as argument to override "null"
.
Keep in mind that this stat sets default mappings only for the x and
y aesthetics: geom_debug()
and geom_text()
are
useful.
A tibble with a summary of the data
received, which is not
printed by default using geom_null()
. Can be printed by passing
geom = "debug"
.
x at centre of range
y at centre of range
nrow()
of data
object
ncol()
of data
object
colnames()
of data
object
class()
of x
and y
columns in data
object
all distinct values in group as passed in data
object
all distinct values in PANEL as passed in data
object
Other diagnosis functions:
stat_debug_group()
my.df <- data.frame(x = rep(1:10, 2),
y = rep(c(1,2), c(10,10)) + rnorm(20),
group = rep(c("A","B"), c(10,10)))
# by default head() is used to show the top rows of data object
# and geom_null() to silence the data returned by the stat
ggplot(my.df, aes(x,y)) +
geom_point() +
stat_debug_panel()
# geom_debug prints the data returned by the stat
ggplot(my.df, aes(x,y)) +
geom_point() +
stat_debug_panel(geom = "debug")
# to print only the the data returned by the stat
# we pass as summary function a function that always returns NULL
ggplot(my.df, aes(x,y)) +
geom_point() +
stat_debug_panel(geom = "debug",
summary.fun = function(x) {NULL})
ggplot(my.df, aes(x,y)) +
geom_point() +
stat_debug_panel(aes(label = sprintf("nrow = %i, ncol = %i, colnames: %s",
after_stat(nrow),
after_stat(ncol),
after_stat(colnames))),
geom = "text")
# here we show all the data object
ggplot(my.df, aes(x,y)) +
geom_point() +
stat_debug_panel(summary.fun = NULL)
ggplot(my.df, aes(x,y)) +
geom_point() +
stat_debug_panel(summary.fun = "nrow")
# with grouping
ggplot(my.df, aes(x,y, colour = group)) +
geom_point() +
stat_debug_panel(summary.fun = NULL)
ggplot(my.df, aes(x,y)) +
geom_point() +
facet_wrap(~group) +
stat_debug_panel()
# by default head() is used to show the top rows of data object
ggplot(my.df, aes(group,y)) +
geom_point() +
stat_debug_panel()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.