This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| snippet dd | |
| devtools::document() | |
| snippet m | |
| `%>%` <- magrittr::`%>%` | |
| snippet l | |
| lubridate:: | |
| snippet > | |
| %>% | |
| snippet p | |
| plotly:: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data("covid19sf_vaccine_demo") | |
| d1 <- covid19sf_vaccine_demo | |
| head(d1) | |
| `%>%` <- magrittr::`%>%` | |
| d1a <- covid19sf_vaccine_demo %>% | |
| dplyr::filter(administering_provider_type == "All Providers", | |
| demographic_group == "Age Bracket", | |
| age_group == "All") %>% | |
| dplyr::mutate(only_1st = total_1st_doses - total_2nd_doses, | |
| not_vaccinated = subgroup_population - total_series_completed - only_1st, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x <- "Plan_Fc.Plan_Fc_Doppler_US" | |
| s <- unlist(regexec(pattern = "\\.", text = x)) + 1 | |
| e <- nchar(x) | |
| substr(x = x, start = s, stop = e) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(cdcfluview) | |
| national_ili <- ilinet("national", years = c(1997:2017)) | |
| mydata.ts <- ts(data = national_ili$total_patients, end = c(2018,39), frequency= 52) | |
| plot(mydata.ts,type="o",col="blue") | |
| plot(forecast(mydata.ts, h = 65)) | |
| library(coronavirus) | |
| library(dplyr) | |
| library(forecast) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(coronavirus) | |
| library(dplyr) | |
| raw <- refresh_coronavirus_jhu() | |
| head(raw) | |
| df <- raw %>% | |
| filter(location == "Israel", | |
| data_type == "cases_new") %>% | |
| select(date, new_cases = value) %>% | |
| arrange(date) | |
| head(df) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Train ARIMA model | |
| md <- arima(x = AirPassengers, order = c(2, 1, 2), seasonal = list(order = c(0, 1, 0))) | |
| # Set number of simulations | |
| n <- 200 | |
| #Run simulation | |
| sim <- parallel::mclapply(1:n, | |
| mc.cores = 12, | |
| function(i){ | |
| fc_sim <- simulate(md, 24) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df <- data.frame(date = seq.Date(from = as.Date("2020-01-01"), | |
| length.out = 100, | |
| by = "week")) %>% | |
| dplyr::mutate(week_index = 1 + (as.numeric(date) - as.numeric(min(date)))/7) | |
| head(df) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(coronavirus) | |
| library(dplyr) | |
| library(plotly) | |
| df <- refresh_coronavirus_jhu() | |
| head(df) | |
| df1 <- df %>% | |
| filter(data_type == "deaths_new") %>% | |
| group_by(location) %>% | |
| summarise(total = sum(value), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(USgas) | |
| data("us_total") | |
| # Set labels | |
| ne <- c("Connecticut", "Maine", "Massachusetts", | |
| "New Hampshire", "Rhode Island", "Vermont") | |
| # Filter the data | |
| ne_gas <- us_total[which(us_total$state %in% ne),] | |
| # Transform to wide format |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Based on this example - https://jkunst.com/highcharter/articles/fontawesome.html | |
| # Data from the USgrid package - https://github.com/RamiKrispin/USgrid | |
| # Icons from - https://fontawesome.com/icons?d=gallery&p=2 | |
| library(fontawesome) | |
| library(highcharter) | |
| library(stringr) | |
| library(dplyr) # to wokr with list columns | |
| library(purrr) # to wokr with list columns |