-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnected_line.R
41 lines (27 loc) · 1.16 KB
/
connected_line.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# =============================================================================
# Connected Line Chart
# =============================================================================
library(tidyverse)
library(hrbrthemes)
# Load the datset from GitHub ---------------------------------------------
data_source <- "https://raw.githubusercontent.com/anirudhjayaraman/covid-19-india/master/downloaded_data/2020-06-06/case_time_series.csv"
datset <- read.table(data_source, header = TRUE, sep = ",")
# change Date to an R Date object
datset$Date <- as.Date(datset$Date) # critical to getting line plot to work
# Basic -------------------------------------------------------------------
p1 <- datset %>%
tail(n = 50) %>%
ggplot(aes(x = Date, y = Total.Confirmed)) +
geom_point() +
geom_line()
plot(p1)
# With theme Ipsum --------------------------------------------------------
p2 <- datset %>%
tail(n = 50) %>%
ggplot(aes(x = Date, y = Total.Confirmed)) +
geom_point() +
geom_line() +
theme_ipsum()
plot(p2)
ggsave(filename = "line_plots/plots/connected_line.png", plot = p2)
# =============================================================================