Code for Quiz 9.
spend_time <- read.csv("https://estanny.com/static/week8/spend_time.csv")
e_charts-1
Start with spend_time -THEN group_by year -THEN create an e_chart that assigns activity to the x-axis and will show activity by year (the variable that you grouped the data on) -THEN use e_timeline_opts to set autoPlay to TRUE -THEN use e_bar to represent the variable avg_hours with a bar chart -THEN use e_title to set the main title to ‘Average hours Americans spend per day on each activity’ -THEN remove the legend with e_legendggplot(spend_time, aes(x = year, y = avg_hours , color = activity)) +
geom_point() +
geom_mark_ellipse(aes(filter = activity == "leisure/sports",
description = "Americans spend on average more time each day on leisure/sports than the other activities"))
msft <- tq_get("MSFT", get = "stock.prices",
from = "2019-08-01", to = "2020-07-28" )
msft %>%
ggplot(aes(x = date, y = close)) +
geom_line() +
geom_mark_ellipse(aes(
filter = date == "2020-03-23",
description = "REPLACE WITH A DESCRIPTION"
), fill = "yellow") +
geom_mark_ellipse(aes(
filter = date == "2020-03-23",
description = "CDC issued its first public alert about coronavirus"
), color = "red", ) +
labs(
title = "SEE Quiz",
x = NULL,
y = "Closing price per share",
caption = "Source: https://en.wikipedia.org/wiki/Timeline_of_the_COVID-19_pandemic_in_the_United_States")
ggsave(filename = "preview.png",
path = here::here("_posts", "2021-04-19-data-visualization"))