-1
  H   ˆl—äY>”*h¥2 Y¸ÛweLZ7ÿ’þBVnQ�n>è�l€Zof¯ùÊÇÆÉ176_‹I|¥Žƒî4ÃVŸÅÍ  °    ‹      }�1Â0E÷œÂ[Ëàdõ0p‚ º%($%vQåî$ªD%$/þÿÛO?Ñ}t‰êJk“çÛÑb}å4Kr¡wÝ³ÚìTúŸ•ˆKÅö%ÿ°	+hàçÔ¡¬gSü’UÆ ±Ï¶ŽíÙš³BÙ0!b� "°íH-pMÓ“p&”Gz:`ž¡^·^ðm±…¢­­à�ÑÙÙéÚ    
   �236ÏÅÍ  ì    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body></html>
  
   �236ÏÅÍ  ì    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body></html>
  
   �236ÏÅÍ  ì    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body></html>
  
   �236ÏÅÍ  ì    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body></html>
  5   ˆl–Ðz¾”ÂXÔÊ�Æž¸ÛŠbÑ¿�þepK7+b\î” þÌƒeö^ËÆÎ b    ## ---- include = FALSE---------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.show = "hide")
library(ggplot2)

## -----------------------------------------------------------------------------
mpg_drv_summary <- function() {
  ggplot2::ggplot(ggplot2::mpg) + 
    ggplot2::geom_bar(ggplot2::aes(x = .data$drv)) + 
    ggplot2::coord_flip()
}

## ---- include=FALSE-----------------------------------------------------------
# make sure this function runs!
mpg_drv_summary()

## -----------------------------------------------------------------------------
#' @importFrom ggplot2 ggplot aes geom_bar coord_flip
mpg_drv_summary <- function() {
  ggplot(ggplot2::mpg) + 
    geom_bar(aes(x = drv)) + 
    coord_flip()
}

## ---- include=FALSE-----------------------------------------------------------
# make sure this function runs!
mpg_drv_summary()

## -----------------------------------------------------------------------------
mpg_drv_summary <- function() {
  ggplot(ggplot2::mpg) + 
    geom_bar(aes(x = drv)) + 
    coord_flip()
}

## -----------------------------------------------------------------------------
mpg_drv_summary <- function() {
  ggplot(ggplot2::mpg) + 
    geom_bar(aes(x = .data$drv)) + 
    coord_flip()
}

## -----------------------------------------------------------------------------
col_summary <- function(df, col) {
  ggplot(df) + 
    geom_bar(aes(x = .data[[col]])) + 
    coord_flip()
}

col_summary(mpg, "drv")

## ---- eval = (packageVersion("rlang") >= "0.3.4.9003")------------------------
col_summary <- function(df, col) {
  ggplot(df) + 
    geom_bar(aes(x = {{ col }})) + 
    coord_flip()
}

col_summary(mpg, drv)

## -----------------------------------------------------------------------------
mpg_drv_dist <- structure(
  c(
    "4" = 103 / 234,
    "f" = 106 / 234,
    "r" = 25 / 234
  ),
  class = "discrete_distr"
)

## -----------------------------------------------------------------------------
discrete_distr_data <- function(x) {
  tibble::tibble(
    value = names(x),
    probability = as.numeric(x)
  )
}

discrete_distr_data(mpg_drv_dist)

## -----------------------------------------------------------------------------
#' @importFrom ggplot2 autoplot
autoplot.discrete_distr <- function(object, ...) {
  plot_data <- discrete_distr_data(object)
  ggplot(plot_data, aes(.data$value, .data$probability)) +
    geom_col() +
    coord_flip() +
    labs(x = "Value", y = "Probability")
}

## -----------------------------------------------------------------------------
#' @importFrom graphics plot
plot.discrete_distr <- function(x, ...) {
  print(autoplot(x, ...))
}

## -------