PACKAGE
library(dplyr)
library(ggplot2)
library(datasauRus)
library(gganimate)DATA
knitr::kable(head(datasaurus_dozen,10))| dataset | x | y |
|---|---|---|
| dino | 55.3846 | 97.1795 |
| dino | 51.5385 | 96.0256 |
| dino | 46.1538 | 94.4872 |
| dino | 42.8205 | 91.4103 |
| dino | 40.7692 | 88.3333 |
| dino | 38.7179 | 84.8718 |
| dino | 35.6410 | 79.8718 |
| dino | 33.0769 | 77.5641 |
| dino | 28.9744 | 74.4872 |
| dino | 26.1538 | 71.4103 |
table(datasaurus_dozen$dataset)##
## away bullseye circle dino dots h_lines
## 142 142 142 142 142 142
## high_lines slant_down slant_up star v_lines wide_lines
## 142 142 142 142 142 142
## x_shape
## 142
SUMMARY
datasaurus_dozen %>%
group_by(dataset) %>%
summarize(mean_x=mean(.$x),
mean_y=mean(.$y),
sd_x=sd(.$x),
sd_y=sd(.$y),
COR=cor(x,y))## # A tibble: 13 × 6
## dataset mean_x mean_y sd_x sd_y COR
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 away 54.2657 47.8351 16.713 26.84777 -0.06412835
## 2 bullseye 54.2657 47.8351 16.713 26.84777 -0.06858639
## 3 circle 54.2657 47.8351 16.713 26.84777 -0.06834336
## 4 dino 54.2657 47.8351 16.713 26.84777 -0.06447185
## 5 dots 54.2657 47.8351 16.713 26.84777 -0.06034144
## 6 h_lines 54.2657 47.8351 16.713 26.84777 -0.06171484
## 7 high_lines 54.2657 47.8351 16.713 26.84777 -0.06850422
## 8 slant_down 54.2657 47.8351 16.713 26.84777 -0.06897974
## 9 slant_up 54.2657 47.8351 16.713 26.84777 -0.06860921
## 10 star 54.2657 47.8351 16.713 26.84777 -0.06296110
## 11 v_lines 54.2657 47.8351 16.713 26.84777 -0.06944557
## 12 wide_lines 54.2657 47.8351 16.713 26.84777 -0.06657523
## 13 x_shape 54.2657 47.8351 16.713 26.84777 -0.06558334
PLOT
ggplot(datasaurus_dozen, aes(x=x, y=y, colour=dataset))+
geom_point(size=1)+
theme_void()+
theme(legend.position = "none")+
facet_wrap(~dataset, ncol=3)p <- ggplot(datasaurus_dozen, aes(x = x, y = y,frame = dataset)) +
geom_point(aes(color=dataset), size=3)+
theme_classic()+
theme(legend.position = "none")
gganimate(p, title_frame = T,"output.gif")Alt text