Drop a few figures
This commit is contained in:
parent
69d813e56b
commit
3421579c61
|
@ -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 |>
|
||||
|
|
Loading…
Reference in New Issue