R covid 19 data analytics projects part 1
R covid 19 data analytics projects part 2
# And the rest of the world?
# Filter confirmed_cases_china_vs_world for not China
not_china <- confirmed_cases_china_vs_world %>%
filter(is_china == "Not China")
# Using not_china, draw a line plot cum_cases vs. date
# Add a smooth trend line using linear regression, no error bars
plt_not_china_trend_lin <- ggplot(not_china, aes(date, cum_cases)) +
geom_line() +
geom_smooth(method = "lm", se = FALSE) +
ylab("Cumulative confirmed cases")
# See the result
plt_not_china_trend_lin
# Adding a logarithmic scale
# Modify the plot to use a logarithmic scale on the y-axis
plt_not_china_trend_lin +
scale_y_log10()
# Which countries outside of China have been hit hardest?
# Run this to get the data for each country
confirmed_cases_by_country <- read_csv("confirmed_cases_by_country.csv")
glimpse(confirmed_cases_by_country)
# Group by country, summarize to calculate total cases, find the top 7
top_countries_by_total_cases <- confirmed_cases_by_country %>%
group_by(country) %>%
summarize(total_cases = max(cum_cases)) %>%
top_n(7, total_cases)
# See the result
top_countries_by_total_cases
Currently you visiting in our blog please Subscribe for more information.