Exploratory analysis

This following post explores the GGplot functionality and abilities.

library(tidyverse)
ggplot(data=faithful,
       mapping = aes(x=eruptions,
                    y=waiting)) + 
  geom_point()

#question: Modify slide 34
FALSE
[1] FALSE
data("faithful")
ggplot(faithful) + 
   geom_point(aes(x = eruptions, y = waiting, 
                  colour = eruptions > 3)) 

#question :Modify slide 35
ggplot(faithful) + 
   geom_point(aes(x = eruptions, y = waiting),
              colour = "purple")  

#question: modify clide 36
ggplot(faithful) + 
   geom_histogram(aes(x = eruptions))   

#questions: modify geom-ex-1

ggplot(faithful) + 
   geom_point(aes(x = eruptions, y = waiting), 
   shape = "triangle", size = 7, alpha =0.5)   

#questions: Modify geom -ex-2
ggplot(faithful) + 
   geom_histogram(aes(x = eruptions, fill = eruptions > 3.2 ))   

#modify stat-slide-40
ggplot(mpg) + 
   geom_bar(aes(x = manufacturer)) 

#modify stat slide -41
mpg_counted <- mpg %>% 
  count(class, name = 'count')
ggplot(mpg_counted) + 
  geom_bar(aes(x = class, y = count), stat = 'identity')

#modify stat slide -43

ggplot(mpg) + 
  geom_bar(aes(x = class, y = after_stat(100 * count / sum(count))))

#question : modify answer to stat ex-2

ggplot(mpg) + 
  geom_jitter(aes(x = class, y = hwy), width = 0.2) +
  stat_summary(aes(x = class, y = hwy), geom = "point", 
  fun = "???", color = "purple", 
  shape = "square", size = 9 )