Plotting Time Series in R: A COVID-19 Example

preview_player
Показать описание

Here I walk through an example showing how I'd plot time-series data in R using the ggplot2 package. In this plot, we look at coronavirus COVID-19 **new** daily cases in the United States and Australia.

🎉 *Enjoyed this video?* Leave a comment below to share what you liked the most!

0:00 Intro
0:15 Download the data
1:00 Read the data into R
1:40 Re-arrange the data to prepare it for plotting
5:18 Plot United States cumulative cases
6:00 Plot United States new daily cases
7:13 "Beautify" the plot (add labels etc.)
9:55 Multiple lines (Australia & US new daily cases)
11:05 Split facets using facet_wrap()
12:15 Remove the legend

Рекомендации по теме
Комментарии
Автор

😃 Comment below to share your own ideas for time-series plots!

tomhenry-datasciencewithr
Автор

This is mind-blowing! I would have never dreamed to get to a so lovely code.

choma
Автор

The best of the video is the data manipulation! Very helpfull!

williammendieta
Автор

thank you for this Tom. Wonder how you would complete a timeseries data that misses a number of dates . e.g. 2022 data that doesn't have 1-20 Aug days

ahmedJaber
Автор

Neat and clean elaboration. Helped me in my project work. Such a life-saving tutorial. Thank you so much. :D

AsrafunNaharAnonna
Автор

New to R and am self-teaching using the R for Data Science book. Your walkthrough was great and easy to follow. Will definitely be watching more of your content!

justinarends
Автор

Excellent tutorial. I wish if you make more of these videos.

muhammedhadedy
Автор

Thank you so much for this. I am new to R and spent an entire day trying to build a similar program but was unsuccessful. This video helped me tremendously in finishing my project.

jorgersoldevilairizarry
Автор

Great video. Clear and concise. Thanks.

susanbenson
Автор

Can you also explain if we set different time intervals as our y axis for the graph

fatimaejaz
Автор

this was useful, clear and loaded with tips.

JobGathirufisher
Автор

Hello Tom, thanks for your videos. I'm traying to display the last value (new cases) of each line as label from this example, how can I do that?

jaimemadrid
Автор

great and useful. I have a big dataset with 500, 000 observation ( some categorical variables (like department, disease, ...) and several datetime which is related to a hospital (Admission date-time, Doctor Note date-time, discharge date-time, ... ). how can I make some discrete time period based on hours, ex: morning (from 6-10 am) to produce informative plots?

farzadraeisi
Автор

Thank you so much. I wonder if you could change the Y-axis scale instead of separating the curves, what would you use?

ahmedalnajar
Автор

Thanks a lot. Your tutorial helped a lot. For your information, your provided code link doesn't work.

crazyghost
Автор

Really nice walkthrough. A couple of cool tips I’d not used before (lag and scales::comma). I would love to see some statistical techniques for forecasting and comparing time series

freddiebrown
Автор

Hello, wonder how to plot the number of cases per year, if I have a date of diagnosis (variable) for each patient(variable)?
thanks

reem
Автор

Thank you for this useful tutorial! I also tried to visualize the covid data in my country but i couldnt replicate yours because everytime i try to plot the date by date on the x axis it wont come out as months like you did, but instead it would be something like (the beginning date) - (kind of middle date) - (last date). I also used lubridate, ggplot, and tidyverse so what should i do to make an output like yours?

swingingarashi
Автор

Do anything similar in Shiny? How about the rate of new cases/population?

MarkIreland_carrierband
Автор

im getting error saying "n_confirmed obj is not found" what to do?

diablo