---
title: "Taller_EDA_3"
author: "Jose Juan"
output:
flexdashboard::flex_dashboard:
orientation: columns
social: menu
source_code: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(plotly)
library(plyr)
library(tidyverse)
library(ggridges)
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
-----------------------------------------------------------------------
### Chart A
```{r}
p<- mpg |> ggplot(aes(x=displ,y=hwy, color=class))+
geom_point()
ggplotly(p)
```
### Chart B
```{r}
# Left
p<-ggplot(mpg, aes(x = displ, y = hwy, color = class)) +
geom_point()
ggplotly(p)
```
Row
-----------------------------------------------------------------------
### Chart C
```{r}
# Right
p<-ggplot(mpg, aes(x = displ, y = hwy, shape = class)) +
geom_point()
ggplotly(p)
```
### Chart D
```{r}
p<-ggplot(mpg) +
geom_point(aes(x = displ, y = hwy, color = "blue"))
ggplotly(p)
```
geom_point
=======================================================================
Row
-----------------------------------------------------------------------
### Chart E
```{r}
p<-ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point(color = "blue")
ggplotly(p)
```
### Chart F
```{r}
# Left
p<-ggplot(mpg, aes(x = displ, y = hwy, size = class)) +
geom_point()
ggplotly(p)
```
Row
-----------------------------------------------------------------------
### Chart G
```{r}
p<-ggplot(mpg, aes(x = displ, y = hwy, size = displ)) +
geom_point()
ggplotly(p)
```
### Chart H
```{r}
p<-ggplot(mpg, aes(x = displ, y = hwy, size = displ, color=displ)) +
geom_point()
ggplotly(p)
```
geom_point
=======================================================================
Row
-----------------------------------------------------------------------
### Chart I
```{r}
# Right
p<-ggplot(mpg, aes(x = displ, y = hwy, alpha = displ)) +
geom_point()
ggplotly(p)
```
### Chart J
```{r}
# Right
p<-ggplot(mpg, aes(x = displ, y = hwy, alpha = displ, color=displ)) +
geom_point()
ggplotly(p)
```
Row
-----------------------------------------------------------------------
### Chart K
```{r}
p<-mpg |>
ggplot(aes(x = displ, y = hwy)) +
geom_point(colour="blue")
ggplotly(p)
```
### Chart L
```{r}
p<-ggplot(mpg, aes(x = displ, y = hwy, color = drv)) +
geom_point() +
geom_smooth(aes(linetype = drv))
ggplotly(p)
```
geom_point
=======================================================================
Row
-----------------------------------------------------------------------
### Chart M
```{r}
p<-ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point(aes(color = class)) +
geom_smooth()
ggplotly(p)
```
### Chart N
```{r}
p<-ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point() +
geom_point(
data = mpg |> filter(class == "2seater"),
color = "red"
) +
geom_point(
data = mpg |> filter(class == "2seater"),
shape = "circle open", size = 5, color = "red"
)
ggplotly(p)
```
Row
-----------------------------------------------------------------------
### Chart O
```{r}
p<-ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point() +
facet_wrap(~cyl)
ggplotly(p)
```
### Chart P
```{r}
p<-ggplot(mpg) +
geom_point(aes(x = displ, y = hwy)) +
facet_wrap(~ class, nrow = 2)
ggplotly(p)
```
geom_point
=======================================================================
Row
-----------------------------------------------------------------------
### Chart U
```{r}
p<-ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point() +
facet_grid(drv ~ cyl)
ggplotly(p)
```
### Chart V
```{r}
p<-ggplot(mpg, aes(x = displ, y = hwy)) +
geom_point() +
facet_grid(drv ~ cyl, scales = "free_y")
ggplotly(p)
```
Row
-----------------------------------------------------------------------
### Chart W
```{r}
p<-ggplot(mpg) +
geom_point(aes(x = displ, y = hwy)) +
facet_grid(drv ~ .)
ggplotly(p)
```
### Chart X
```{r}
p<-ggplot(mpg) +
geom_point(aes(x = displ, y = hwy)) +
facet_grid(. ~ cyl)
ggplotly(p)
```
geom_density
=======================================================================
Row
-----------------------------------------------------------------------
### Chart Q
```{r}
p<-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)
ggplotly(p)
```
### Chart R
```{r}
# Imitating a ridgeline plot
p<-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)
)
)
ggplotly(p)
```
Row
-----------------------------------------------------------------------
### Chart S
```{r}
ggplot(mpg, aes(x = hwy, y = drv, fill = drv, color = drv)) +
geom_density_ridges(alpha = 0.5, show.legend = TRUE)
```
### Chart T
```{r}
p<-ggplot(mpg, aes(class, hwy)) +
geom_boxplot(aes(colour = class, fill = class))
ggplotly(p)
```
geom_bar
=======================================================================
Row
-----------------------------------------------------------------------
### Chart Y
```{r}
p<-ggplot(mpg, aes(class, hwy)) +
geom_boxplot(aes(colour = class, fill = after_scale(alpha(colour, 0.4))))
ggplotly(p)
```
### Chart Z
```{r}
# Left
p<-ggplot(mpg, aes(x = drv, color = drv)) +
geom_bar()
ggplotly(p)
```
Row
-----------------------------------------------------------------------
### Chart AA
```{r}
# Right
p<-ggplot(mpg, aes(x = drv, fill = drv)) +
geom_bar()
ggplotly(p)
```
### Chart AB
```{r}
p<-ggplot(mpg, aes(x = drv, fill = class)) +
geom_bar()
ggplotly(p)
```
geom_bar
=======================================================================
Row
-----------------------------------------------------------------------
### Chart AC
```{r}
p<-ggplot(mpg, aes(x = drv, fill = class)) +
geom_bar(alpha = 1/2, position = "identity")
ggplotly(p)
```
### Chart AD
```{r}
# Right
p<-ggplot(mpg, aes(x = drv, color = class)) +
geom_bar(fill = NA, position = "identity")
ggplotly(p)
```
Row
-----------------------------------------------------------------------
### Chart AE
```{r}
# Left
p<-ggplot(mpg, aes(x = drv, fill = class)) +
geom_bar(position = "fill")
ggplotly(p)
```
### Chart AF
```{r}
# Right
p<-ggplot(mpg, aes(x = drv, fill = class)) +
geom_bar(position = "dodge")
ggplotly(p)
```