Description Usage Arguments Details Value Author(s) Examples
Convert a tibble built using freq_table
or cont_table
in a
shape that makes it easy to plot.
1 2 3 4 5 6 7 8 9 10 11 12 |
data |
a tibble returned by the |
f |
mandatory argument if the tibble contains more than one frequency or density, |
plot |
for object of class |
... |
further arguments. |
The pre_plot
function returns a tibble containing:
if plot = histogram
, x
, y
that should be
passed to geom_polygon
,
if plot = freqpoly
x
and y
that should be passed to geom_line
,
if plot = stacked
x
and ypos
that should be passed
respectively to geom_col
and to geom_text
to draw labels on
the right position,
if plot = cumulative
x
, y
, xend
and yend
that should be passed to
geom_segment
,
if plot = lorenz
for the Lorenz curve, F
and M
for the
coordinates of the polygons under the Lorenz curve, pts
is
logical which the defines the subset of points that belongs to the
Lorenz curve.
a tibble
Yves Croissant
1 2 3 4 5 6 7 8 9 10 11 12 13 | library("dplyr")
library("ggplot2")
pad <- padova %>%
freq_table(price, breaks = c(100, 200, 300, 400, 500, 1000),
right = TRUE, f = "Npd")
pad %>% pre_plot(f = "d") %>% ggplot() + geom_polygon(aes(x, y))
pad %>% pre_plot(f = "d", plot = "freqpoly") %>%
ggplot() + geom_line(aes(x, y))
## A pie chart
wages %>% freq_table(sector, "p", total = FALSE) %>%
pre_plot("p", plot = "stacked") %>% ggplot(aes(x = 2, y = p, fill = sector)) +
geom_col() + geom_text(aes(y = ypos, label = sector)) +
coord_polar(theta = "y") + theme_void() + guides(fill = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.