#aaaaa
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source_code: embed
vertical_layout: scroll
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
# Make some noisily increasing data
set.seed(955)
dat <- data.frame(cond = rep(c("A", "B"), each=10),
xvar = 1:20 + rnorm(20,sd=3),
yvar = 1:20 + rnorm(20,sd=3))
```
geom_point
=======================================================================
Row
-----------------------------------------------------------------------
### Scatter Chart with geom_point
```{r , echo=FALSE, warning=FALSE, error=FALSE,}
# Left
ggplot(mpg, aes(x = displ, y = hwy, color = class)) +
geom_point()
```
### algo
```{r , echo=FALSE, warning=FALSE, error=FALSE,}
mpg |>
ggplot(aes(x = displ, y = hwy, color = class)) +
geom_point()
```
Row
-----------------------------------------------------------------------
### geom_smooth with Loess Smoothed Fit
```{r , echo=FALSE, warning=FALSE, error=FALSE,}
mpg |>
ggplot()+
geom_point(aes(x = displ, y = hwy, color = class))
```
#aaaaa
```{r , echo=FALSE, warning=FALSE, error=FALSE,}
# Right
ggplot(mpg, aes(x = displ, y = hwy, shape = class)) +
geom_point()
```
### Chart E
```{r}
ggplot(mpg) +
geom_point(aes(x = displ, y = hwy, color = "blue"))
```
Row
-----------------------------------------------------------------------
### Chart F
```{r}
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point(color = "blue")
```
### Chart G
```{r}
# Left
ggplot(mpg, aes(x = displ, y = hwy, size = class)) +
geom_point()
```
Row
-----------------------------------------------------------------------
### Chart G
```{r}
ggplot(mpg, aes(x = displ, y = hwy, size = displ)) +
geom_point()
```
### Chart H
```{r}
ggplot(mpg, aes(x = displ, y = hwy, size = displ, color=trans)) +
geom_point()
```
Row
-----------------------------------------------------------------------
### Chart I
```{r}
ggplot(mpg, aes(x = displ, y = hwy, size = displ, color=displ)) +
geom_point()
```
### Chart j
```{r}
# Right
ggplot(mpg, aes(x = displ, y = hwy, alpha = displ)) +
geom_point()
```
Row
-----------------------------------------------------------------------
### Chart K
```{r}
# Right
ggplot(mpg, aes(x = displ, y = hwy, alpha = displ, color=displ)) +
geom_point()
```
### Chart L
```{r}
mpg |>
ggplot(aes(x = displ, y = hwy)) +
geom_point(colour="blue")
```
Row
-----------------------------------------------------------------------
### Chart M
```{r}
ggplot(mpg, aes(x = displ, y = hwy, color = drv)) +
geom_point() +
geom_smooth(aes(linetype = drv))
```
### Chart N
```{r}
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point(aes(color = class)) +
geom_smooth()
```
Row
-----------------------------------------------------------------------
### Chart O
```{r}
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point() +
geom_point(
data = mpg |> dplyr::filter(class == "2seater"),
color = "red"
) +
geom_point(
data = mpg |> dplyr::filter(class == "2seater"),
shape = "circle open", size = 5, color = "red"
)
```
### Chart P
```{r}
ggplot(mpg, aes(class, hwy)) +
geom_boxplot(aes(colour = class, fill = class))
```
### Chart Q
```{r}
ggplot(mpg, aes(class, hwy)) +
geom_boxplot(aes(colour = class, fill = after_scale(alpha(colour, 0.4))))
```
Row
-----------------------------------------------------------------------
### Chart R
```{r}
# Making a proportional stacked density plot
ggplot(mpg, aes(cty)) +
geom_density(
aes(
colour = factor(cyl),
fill = after_scale(alpha(colour, 0.3)),
y = after_stat(count / sum(n[!duplicated(group)]))
),
position = "stack", bw = 1
) +
geom_density(bw = 1)
```
### Chart S
```{r}
# Imitating a ridgeline plot
ggplot(mpg, aes(cty, colour = factor(cyl))) +
geom_ribbon(
stat = "density", outline.type = "upper",
aes(
fill = after_scale(alpha(colour, 0.3)),
ymin = after_stat(group),
ymax = after_stat(group + ndensity)
)
)
```
```{r}
library(ggridges)
```
Row
-----------------------------------------------------------------------
### Chart U
```{r}
ggplot(mpg, aes(x = hwy, y = drv, fill = drv, color = drv)) +
geom_density_ridges(alpha = 0.5, show.legend = FALSE)
#> Picking joint bandwidth of 1.28
```
### Chart V
```{r}
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point() +
facet_wrap(~cyl)
```
### Chart X
```{r}
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point() +
facet_grid(drv ~ cyl)
```
Row
-----------------------------------------------------------------------
### Chart y
```{r}
ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point() +
facet_grid(drv ~ cyl, scales = "free_y")
```
### Chart z
```{r}
ggplot(mpg) +
geom_point(aes(x = displ, y = hwy)) +
facet_grid(drv ~ .)
```
Row
-----------------------------------------------------------------------
### Chart AA
```{r}
ggplot(mpg) +
geom_point(aes(x = displ, y = hwy)) +
facet_grid(. ~ cyl)
```
### Chart AB
```{r}
ggplot(mpg) +
geom_point(aes(x = displ, y = hwy)) +
facet_wrap(~ class, nrow = 2)
```
Row
-----------------------------------------------------------------------
### Chart AC
```{r}
# Left
ggplot(mpg, aes(x = drv, color = drv)) +
geom_bar()
```
### Chart AD
```{r}
# Right
ggplot(mpg, aes(x = drv, fill = drv)) +
geom_bar()
```
Row
-----------------------------------------------------------------------
### Chart AE
```{r}
ggplot(mpg, aes(x = drv, fill = class)) +
geom_bar()
```
### Chart AF
```{r}
ggplot(mpg, aes(x = drv, fill = class)) +
geom_bar(alpha = 1/2, position = "identity")
```
Row
-----------------------------------------------------------------------
### Chart AG
```{r}
# Right
ggplot(mpg, aes(x = drv, color = class)) +
geom_bar(fill = NA, position = "identity")
```
### Chart AH
```{r}
# Left
ggplot(mpg, aes(x = drv, fill = class)) +
geom_bar(position = "fill")
```
Row
-----------------------------------------------------------------------
### Chart AI
```{r}
# Right
ggplot(mpg, aes(x = drv, fill = class)) +
geom_bar(position = "dodge")
```