-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
library(openxlsx)
library(tibble)
library(lubridate)
library(zoo)
db <- openxlsx::read.xlsx(
xlsxFile = "~/Downloads/Corona 01.04.2022.xlsx",
sheet = "Tabelle1"
)
db <- as_tibble(db)
for (i in 2:5){
new_col <- gsub("\\.", "", db[[i]])
new_col <- gsub("^.*?(\\d+).*?$", "\\1", new_col, perl = TRUE)
db[[i]] <- as.integer(new_col)
}
date_raw <- gsub("^.*?(\\d.*\\d).*?$", "\\1", db[["Datum"]])
db[["Datum"]] <- as.Date(date_raw, format = "%d.%m.%Y")
colnames(db) <- c("date", "cases_confirmed", "infected", "recovered", "died")
db_sorted <- db[order(db$date),]
db_sorted[["new"]] <- c(
NA,
db_sorted$cases_confirmed[2:nrow(db_sorted)] - db_sorted$cases_confirmed[1:(nrow(db_sorted) - 1)]
)
db_sorted$month <- as.yearmon(db_sorted$date)
y <- aggregate(
x = db_sorted[, c("month", "new")],
by = list(mon = db_sorted$month),
mean, na.rm = TRUE
)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels