Skip to content

Commit

Permalink
Merge pull request #113 from miraisolutions/develop
Browse files Browse the repository at this point in the history
Release 2.0.0
  • Loading branch information
GuidoMaggio authored Jul 3, 2020
2 parents 016306e + bc51fd0 commit 092dae1
Show file tree
Hide file tree
Showing 56 changed files with 1,225 additions and 658 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Covid19
Package: Covid19Mirai
Title: Covid-19 Data Analysis
Version: 1.2.2
Version: 2.0.0
Authors@R:
c(person("Francesca", "Vitalini", role = c("cre", "aut"),
email = 'francesca.vitalini@mirai-solutions.com'),
Expand Down Expand Up @@ -38,6 +38,7 @@ Imports:
sp,
markdown,
scales,
COVID19,
grDevices,
rlang,
zoo
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ export(from_contagion_day_bar_plot)
export(getTableOptions)
export(get_Covid19_version)
export(get_daily_data)
export(get_datahub)
export(get_date_data)
export(get_pop_data)
export(get_pop_datahub)
export(get_timeseries_by_contagion_day_data)
export(get_timeseries_country_data)
export(get_timeseries_data)
Expand All @@ -33,6 +35,7 @@ export(get_timeseries_global_data)
export(get_timeseries_province_data)
export(get_timeseries_single_data)
export(load_countries_data_map)
export(load_countries_datahub_map)
export(merge_pop_data)
export(new_case_colors)
export(new_total_colors)
Expand Down Expand Up @@ -60,6 +63,7 @@ import(sp)
import(stringr)
import(tidyr)
import(zoo)
importFrom(COVID19,covid19)
importFrom(DT,DTOutput)
importFrom(DT,datatable)
importFrom(DT,renderDT)
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### Covid19Mirai 2.0.0
- Update data source from covid19datahub (#104)
https://github.com/covid19datahub/COVID19
- Population size taken from covid19datahub, some variables over 1M will differ
- Package name renamed to Covid19Mirai to avoid conflict with COVID19
- SP data saved in RDS for faster reading
- updated info on data source, updated ReadMe page
- correction on color palette for new active maps when there are no negative values

### Covid19 1.2.2 (2020-06-23)
- Fix colors in lineplot (#95)
- Align graph colors in continent map (#105)
Expand Down
26 changes: 13 additions & 13 deletions R/app_config.R
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
#' Access files in the current app
#'
#'
#' @param ... Character vector specifying directory and or file to
#' point to inside the current package.
#'
#'
#' @noRd
app_sys <- function(...){
system.file(..., package = "Covid19")
system.file(..., package = "Covid19Mirai")
}


#' Read App Config
#'
#' @param value Value to retrieve from the config file.
#' @param config R_CONFIG_ACTIVE value.
#'
#' @param value Value to retrieve from the config file.
#' @param config R_CONFIG_ACTIVE value.
#' @param use_parent Logical, scan the parent directory for config file.
#'
#'
#' @importFrom config get
#'
#'
#' @noRd
get_golem_config <- function(
value,
config = Sys.getenv("R_CONFIG_ACTIVE", "default"),
value,
config = Sys.getenv("R_CONFIG_ACTIVE", "default"),
use_parent = TRUE
){
config::get(
value = value,
config = config,
value = value,
config = config,
# Modify this if your config file is somewhere else:
file = app_sys("golem-config.yml"),
file = app_sys("golem-config.yml"),
use_parent = use_parent
)
}
Expand Down
61 changes: 26 additions & 35 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@
#' @noRd
app_server <- function(input, output, session) {

#profvis({
# Params ----
n <- 1000 # min number of cases for a country to be considered. Default 1000
w <- 7 # number of days of outbreak. Default 7

# Data ----
# map
countries_data_map <- load_countries_data_map(destpath = system.file("./countries_data", package = "Covid19"))
orig_data <- reactive({
get_timeseries_full_data() %>%
#countries_data_map <- load_countries_datahub_map(destpath = system.file("./countries_data", package = "Covid19Mirai"))
rds_map = "WorldMap_sp_rds"
message("read map from RDS ", rds_map)
countries_data_map = readRDS(file = file.path(system.file("./countries_data", package = "Covid19Mirai"),rds_map))

orig_data <- #reactive({
get_datahub() %>%
get_timeseries_by_contagion_day_data()
})
#})

pop_data = get_pop_data()
pop_data = get_pop_datahub()

#align continents from map with pop
#country_name <- as.character(unique(as.character(countries_data_map$NAME))[charmatch(pop_data$Country.Region, unique(as.character(countries_data_map$NAME)))])
Expand All @@ -44,49 +49,35 @@ app_server <- function(input, output, session) {
pop_data = res$pop
countries_data_map = res$map
# remove small countries, population <=1000
pop_data = pop_data %>% filter(population >1000)
# clean countries_data_map
orig_data_aggregate <- reactive({
orig_data_aggregate <- orig_data() %>%
aggregate_province_timeseries_data() %>%
add_growth_death_rate() %>%
arrange(Country.Region) %>%
#align_country_names_pop() %>%
merge_pop_data(pop_data) %>% # compute additional variables
#align_country_names_pop_reverse() %>%
mutate(mortality_rate_1M_pop = round(10^6*deaths/population, digits = 3),
prevalence_rate_1M_pop = round(10^6*confirmed/population, digits = 3),
new_prevalence_rate_1M_pop = round(10^6*new_confirmed/population, digits = 3))
orig_data_aggregate
})
# TODO pop_data = pop_data %>% filter(population >1000)

orig_data_aggregate <-
build_data_aggr(orig_data, pop_data)


output$last_update <- renderText({
paste0("Last updated: ",
max(orig_data()$date)
max(orig_data$date)
)
})

data_filtered <- reactive({
orig_data_aggregate() %>%
data_filtered <-
orig_data_aggregate %>%
rescale_df_contagion(n = n, w = w)
})


countries <- reactive({
data_filtered() %>%
data_filtered %>%
select(Country.Region) %>%
distinct()
})


# continents <- reactive({
# data_filtered() %>%
# select(continent) %>%
# distinct()
# })

# Modules ----

callModule(mod_global_server, "global", orig_data = orig_data, orig_data_aggregate = orig_data_aggregate,
data_filtered = data_filtered, countries_data_map)

callModule(mod_continent_comparison_server, "continent_comparison", orig_data_aggregate = orig_data_aggregate, n = n, w = w, pop_data = pop_data)

# select continents in tabs
Expand All @@ -98,12 +89,10 @@ app_server <- function(input, output, session) {
orig_data_aggregate = orig_data_aggregate, n = n, w = w,
pop_data = pop_data, countries_data_map = countries_data_map,
cont = continents[i.cont], uicont = uicontinents[i.cont])

}
callModule(mod_country_server, "country", data_filtered = data_filtered, countries = countries, n = n, w = w)


callModule(mod_country_server, "country", orig_data_aggregate = orig_data_aggregate, data_filtered = data_filtered, countries = countries, n = n, w = w)
callModule(mod_country_comparison_server, "country_comparison", orig_data_aggregate = orig_data_aggregate, data_filtered = data_filtered, countries = countries, n = n, w = w)
callModule(mod_country_comparison_server, "country_comparison", data_filtered = data_filtered, countries = countries, n = n, w = w)

# Modal ----
# what is new pop-up
Expand All @@ -117,5 +106,7 @@ app_server <- function(input, output, session) {
fade = FALSE
))
})
#})

}

10 changes: 7 additions & 3 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ app_ui <- function(request) {
),
a(
# href = "https://github.com/CSSEGISandData/COVID-19",
href = "https://github.com/bumbeishvili/covid19-daily-data",
#href = "https://github.com/bumbeishvili/covid19-daily-data",
href = "https://covid19datahub.io/",
target = "_blank",
span(
id = "subtitle",
"Data source: worldometers from 26.03.2020, JHU CSSE before.",
#"Data source: worldometers from 26.03.2020, JHU CSSE before.",
"Data source: COVID-19 Data Hub",
textOutput("last_update", inline = TRUE) %>%
bs_embed_tooltip(title = "Data Repository by bumbeishvili. More information on the README.", placement = "right")
#bs_embed_tooltip(title = "Data Repository by bumbeishvili. More information on the README.", placement = "right")
bs_embed_tooltip(title = "Data Repository by COVID-19 Data Hub. More information in the README on our github page.", placement = "right")

)
)
), # end header-left
Expand Down
2 changes: 1 addition & 1 deletion R/get_Covid19_version.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
#'
#' @export
get_Covid19_version <- function() {
as.character(utils::packageVersion("Covid19"))
as.character(utils::packageVersion("Covid19Mirai"))
}
Loading

0 comments on commit 092dae1

Please sign in to comment.