120,110,170,180,176,171,101 cms. - Your job is to select t-shirt sizes for them. - How many small t-shirts and how many large t-shirts ? - What else can we infer about this family ?
library(tidyverse)
height_data <- data_frame(name = c("Anil","Bobby","Manju","Rekha","Peter","Rohit","Ananya"),
height = c(120,110,170,180,176,171,101))
height_data %>% ggplot(aes(name,height)) + geom_point(size = 2) + theme_minimal() +
theme(axis.title.x = element_text(size = 10),
axis.title.y = element_text(size = 10))
“Visualizations can surprise you !” - Hadley Wickham
3 small children, 2 parents, and 2 grandparents.
Therefore: 3 small t-shirts and 4 large t-shirts!
height_data %>% kable()
| name | height |
|---|---|
| Anil | 120 |
| Bobby | 110 |
| Manju | 170 |
| Rekha | 180 |
| Peter | 176 |
| Rohit | 171 |
| Ananya | 101 |
height_data %>% arrange(height) %>% kable()
| name | height |
|---|---|
| Ananya | 101 |
| Bobby | 110 |
| Anil | 120 |
| Manju | 170 |
| Rohit | 171 |
| Peter | 176 |
| Rekha | 180 |
height_data %>% ggplot(aes(height)) + geom_bar() +
theme_minimal() + theme(axis.title = element_text(size = 10))
height_data %>% ggplot(aes(name,height)) + geom_point(size = 2) +
theme_minimal() + theme(axis.title = element_text(size = 10))
height_data %>%
mutate(state = c("KA","KA","TN","KA","KA","TN","KA")) -> height_data
height_data %>%
ggplot(aes(name,height, color = state)) + geom_point(size = 2) +
theme_minimal() + theme(axis.title = element_text(size = 10))
Possible scenario : Grandparents live in TN; parents and children live in KA!
height_data %>%
mutate(favorite_sport = c("Soccer","Soccer","Cricket","Hockey",
"Soccer","Hockey","Soccer")) %>%
ggplot(aes(name,height, color = state, shape = favorite_sport)) +
geom_point(size = 5) +
theme_minimal() + theme(axis.title = element_text(size = 10))
Children like soccer !
Install R
Install R-Studio https://rstudio.com
Open R-Studio and run
install.packages(“tidyverse”)