cecilesauder/satRdayFlightsFever

switch to ggplot2

Closed this issue · 3 comments

Pour le graph de saisonnalité:

ggplot( data, aes( x = month, y = passengers, group = year, color = year) ) +
  geom_line() + 
  geom_point()

ggplot

@cecilesauder tu peux intégrer ça à l'appli stp ?

C'est mieux si la variable year est un facteur:

data <- flights %>% 
  filter( direction == "Outgoing" ) %>%
  mutate( year = as.factor(year) ) %>%
  group_by( year, month ) %>%
  summarise( passengers = sum( passengers )) 


ggplot( data ) +
  aes( x = month, y = passengers, 
       group = year, color = year
  ) +
  geom_line() + 
  geom_point()

ggplot2

data <- flights %>% 
  filter( direction == "Outgoing" ) %>%
  mutate( 
    year = as.factor(year), 
    month = factor( month.abb[month], levels = month.abb ) 
  ) %>%
  group_by( year, month ) %>%
  summarise( passengers = sum( passengers )) 

ggplot( data ) +
  aes( x = month, y = passengers, 
       group = year, color = year
  ) +
  geom_line() + 
  geom_point()