From 3421579c61e4153328436e71935f47a7c6dda700 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Tue, 24 Jan 2023 09:55:34 -0600 Subject: [PATCH] Drop a few figures --- functions.qmd | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/functions.qmd b/functions.qmd index c57234f..5aa1bb3 100644 --- a/functions.qmd +++ b/functions.qmd @@ -691,6 +691,7 @@ Note that `histogram()` returns a ggplot2 plot, meaning you can still add on add Just remember to switch from `|>` to `+`: ```{r} +#| fig.show: hide diamonds |> histogram(carat, 0.1) + labs(x = "Size (in carats)", y = "Number of diamonds") @@ -707,8 +708,8 @@ linearity_check <- function(df, x, y) { df |> ggplot(aes(x = {{ x }}, y = {{ y }})) + geom_point() + - geom_smooth(method = "loess", color = "red", se = FALSE) + - geom_smooth(method = "lm", color = "blue", se = FALSE) + geom_smooth(method = "loess", formula = y ~ x, color = "red", se = FALSE) + + geom_smooth(method = "lm", formula = y ~ x, color = "blue", se = FALSE) } starwars |> @@ -825,6 +826,8 @@ As with data frame functions, it can be useful to make your plotting functions t For example, the following function makes it particularly easy to interactively explore the conditional distribution of `carat` from the diamonds dataset. ```{r} +#| fig.show: hide + # https://twitter.com/yutannihilat_en/status/1574387230025875457 density <- function(color, facets, binwidth = 0.1) { diamonds |>