Plot time series of a country's cases

plot_ts(
  x,
  area,
  area_col = "countryEnglishName",
  date_col = "date",
  ts_col = c("confirmedCount", "curedCount", "deadCount")
)

Arguments

x

a datafram with "countryEnglishName", "date", "confirmed", "cured", "dead" columns

area

name of an selected area

area_col

the column name of the area in x

date_col

the column name of the date in x

ts_col

the column names of the time series in x

Value

a figure

Examples

ncov_raw <- get_ncov()
#> Warning: InternetOpenUrl failed: 'The server name or address could not be resolved'
#> Error in readRDS(gzcon(url("https://github.com/pzhaonet/ncov/raw/master/static/data-download/ncov.RDS"))) : #> cannot open the connection
#> No encoding supplied: defaulting to UTF-8.
#> Parsed with column specification: #> cols( #> City = col_character(), #> City_Admaster = col_character(), #> City_EN = col_character(), #> Province = col_character(), #> Province_EN = col_character(), #> Region = col_character(), #> Tier = col_character() #> )
#> No encoding supplied: defaulting to UTF-8.
#> Error: lexical error: invalid char in json text. #> <html> <head><title>503 Servic #> (right here) ------^
ncov_raw$area$date <- as.Date(ncovr:::conv_time(ncov_raw$area$updateTime))
#> Error in ncovr:::conv_time(ncov_raw$area$updateTime): object 'ncov_raw' not found
x <- ncov_raw$area[, c("countryEnglishName", "countryName", "date", "confirmedCount", "curedCount", "deadCount")] %>% roup_by(countryEnglishName, date) %>% summarise(confirmed = sum(confirmedCount), cured = sum(curedCount), dead = sum(deadCount)) %>% ungroup()
#> Error in eval(lhs, parent, parent): object 'ncov_raw' not found
x <- x[!is.na(x$countryEnglishName) & !x$countryEnglishName == "China", ]
#> Error in eval(expr, envir, enclos): object 'x' not found
plot_ts(x, area = "Korea")
#> Error in seq.Date(from = min(x[, date_col]), to = max(x[, date_col]), by = 1): object 'x' not found