Scatterplot

Using Star Wars Data set

We can see the differences between the Star Wars Movie series male and female characters in height and weight. We found out that the height and weight of most male characters are more than of the female characters

library(tidyverse)
library(ggplot2)

swdataset<-starwars %>% 
  drop_na()

sw <- ggplot(swdataset, aes(x=height, y=mass)) + 
  geom_point(aes(col=gender), shape = "diamond", size=3) +
  geom_line(color = "firebrick", linetype = "dotted", lwd = .3)+
  geom_smooth(method="glm", col="purple", size=1) + 
  labs(title="Male vs. Female Characters", 
       subtitle="From Starwars dataset", 
       y="Height", x="Weight", 
       caption="Height and Weight Differnces")+
       theme_test()
sw

Barplot

Using the sleep dataset

We can sleep how much extra hours students slept according to their ID numbers in two different groups. From the plotting it’s easier to spot that the group 1 is much more deprived from sleep, where group 2 sleeps more extra hours

library(ggplot2)

slp <-ggplot(sleep, aes(x = extra, y = ID)) +
   geom_bar(stat="identity", fill="skyblue")+
   geom_text(aes(label= extra), vjust = 1, color="firebrick")+
   labs(title="Student Extra Sleep Hours", 
        subtitle="According to Thier Groups",
        x = "Extra Sleep Hours", 
        y = "Student ID")+
   theme_classic() + facet_wrap(~group) + coord_flip()

slp

Animation

Using the Tooth Growth Data set

We can see the effects of the both supplements on tooth growth in Guinea pigs. We can clearly see the effects of growth of tooth by each different dose of supplements applied. Here, OJ needs to be applied more while the tooth is smaller and VC needs to be applied more while the tooth is bigger

library(tidyverse)
library(gganimate)

tg <- ToothGrowth %>% 
  ggplot(aes(dose, len, fill = supp)) +
  geom_jitter() +
  geom_boxplot() +
  labs(title = "Guinea pigs Tooth Growth", x = "Dose in milligrams", y = "Tooth length") +
  transition_states(dose) +
  shadow_wake(wake_length = 0.02) +
  ease_aes('linear') +
  theme_minimal()

tg

anim_save("Guinea_Pig_Tooth_Growth.gif", tg)