Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
mralbu committed Mar 21, 2021
1 parent c17fd55 commit 9e0eeaf
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 15 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Imports:
shinythemes,
pkgload,
rlang,
config
config,
zoo
RoxygenNote: 7.0.2
URL: https://github.com/mralbu/coronavirusbrazil
BugReports: https://github.com/mralbu/coronavirusbrazil/issues
Expand Down
6 changes: 3 additions & 3 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ app_server = function(input, output) {

g = coronavirusbrazil::plot_coronavirus(coronavirusbrazil::coronavirus_world,
input$xaxis_world, input$yaxis_world, color="country",
log_scale=input$log_scale_world, smooth=input$linear_smooth_world,
log_scale=input$log_scale_world, smooth=FALSE,
filter_variable="country", filter_values=input$filter_country_world,
facet=dplyr::if_else(input$facet_country_world, "country", NULL))
g %>% plotly::ggplotly()
Expand All @@ -20,7 +20,7 @@ app_server = function(input, output) {

g = coronavirusbrazil::plot_coronavirus(coronavirusbrazil::coronavirus_br_states,
input$xaxis_states, input$yaxis_states, color="state",
log_scale=input$log_scale_states, smooth=input$linear_smooth_states,
log_scale=input$log_scale_states, smooth=FALSE,
filter_variable="state", filter_values=input$filter_uf_states,
facet=dplyr::if_else(input$facet_uf_states, "state", NULL))
g %>% plotly::ggplotly()
Expand All @@ -30,7 +30,7 @@ app_server = function(input, output) {

g = coronavirusbrazil::plot_coronavirus(coronavirusbrazil::coronavirus_br_cities,
input$xaxis_cities, input$yaxis_cities, color="city",
log_scale=input$log_scale_cities, smooth=input$linear_smooth_cities,
log_scale=input$log_scale_cities, smooth=FALSE,
filter_variable="city", filter_values=input$filter_cities,
facet=dplyr::if_else(input$facet_cities, "city", NULL))
g %>% plotly::ggplotly()
Expand Down
18 changes: 9 additions & 9 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ app_ui = function() {
shiny::tabPanel("Países",
shiny::sidebarLayout(
shiny::sidebarPanel(
shiny::selectInput("yaxis_world", "Eixo y", choices = list(Casos="cases", Mortes="deaths", Mortalidade="death_rate", `Variação de Casos`="new_cases", `Variação de Mortes`="new_deaths", `Variação de Casos (%)`="percent_case_increase", `Variação de Mortes (%)`="percent_death_increase")),
shiny::selectInput("yaxis_world", "Eixo y", selected = "new_deaths", choices = list(Casos="cases", Mortes="deaths", Mortalidade="death_rate", `Variação de Casos`="new_cases", `Variação de Mortes`="new_deaths", `Variação de Casos (%)`="percent_case_increase", `Variação de Mortes (%)`="percent_death_increase")),
shiny::selectInput("xaxis_world", "Eixo X", choices = list(Data="date", `Dias depois de 10 Casos`="days_gt_10",
`Dias depois de 100 Casos`="days_gt_100", `Casos Acumulados`="cases")),
shiny::selectInput("filter_country_world", "Países", multiple = TRUE, choices = sort(unique(coronavirusbrazil::coronavirus_world$country)), selected = c("Brazil")),
shiny::checkboxInput("log_scale_world", "Escala Log", value = TRUE),
shiny::checkboxInput("log_scale_world", "Escala Log", value = FALSE),
shiny::checkboxInput("facet_country_world", "Gráficos Individuais", value = TRUE),
shiny::checkboxInput("linear_smooth_world", "Tendência")
# shiny::checkboxInput("linear_smooth_world", "Tendência")
),
shiny::mainPanel(
plotly::plotlyOutput("plot_countries")
Expand All @@ -27,13 +27,13 @@ app_ui = function() {
shiny::tabPanel("Estados",
shiny::sidebarLayout(
shiny::sidebarPanel(
shiny::selectInput("yaxis_states", "Eixo y", choices = list(Casos="cases", Mortes="deaths", Mortalidade="death_rate", `Variação de Casos`="new_cases", `Variação de Mortes`="new_deaths", `Variação de Casos (%)`="percent_case_increase", `Variação de Mortes (%)`="percent_death_increase")),
shiny::selectInput("yaxis_states", "Eixo y", selected="new_deaths", choices = list(Casos="cases", Mortes="deaths", Mortalidade="death_rate", `Variação de Casos`="new_cases", `Variação de Mortes`="new_deaths", `Variação de Casos (%)`="percent_case_increase", `Variação de Mortes (%)`="percent_death_increase")),
shiny::selectInput("xaxis_states", "Eixo X", choices = list(Data="date", `Dias depois de 10 Casos`="days_gt_10",
`Dias depois de 100 Casos`="days_gt_100", `Casos Acumulados`="cases")),
shiny::selectInput("filter_uf_states", "Estados", multiple = TRUE, choices = sort(unique(coronavirusbrazil::coronavirus_br_states$state)), selected = c("SP", "RJ")),
shiny::checkboxInput("log_scale_states", "Escala Log", value = TRUE),
shiny::checkboxInput("log_scale_states", "Escala Log", value = FALSE),
shiny::checkboxInput("facet_uf_states", "Gráficos Individuais", value = TRUE),
shiny::checkboxInput("linear_smooth_states", "Tendência")
# shiny::checkboxInput("linear_smooth_states", "Tendência")
),
shiny::mainPanel(
plotly::plotlyOutput("plot_states")
Expand All @@ -43,13 +43,13 @@ app_ui = function() {
shiny::tabPanel("Cidades",
shiny::sidebarLayout(
shiny::sidebarPanel(
shiny::selectInput("yaxis_cities", "Eixo y", choices = list(Casos="cases", Mortes="deaths", Mortalidade="death_rate", `Variação de Casos`="new_cases", `Variação de Mortes`="new_deaths", `Variação de Casos (%)`="percent_case_increase", `Variação de Mortes (%)`="percent_death_increase")),
shiny::selectInput("yaxis_cities", "Eixo y", selected="new_deaths", choices = list(Casos="cases", Mortes="deaths", Mortalidade="death_rate", `Variação de Casos`="new_cases", `Variação de Mortes`="new_deaths", `Variação de Casos (%)`="percent_case_increase", `Variação de Mortes (%)`="percent_death_increase")),
shiny::selectInput("xaxis_cities", "Eixo X", choices = list(Data="date", `Dias depois de 10 Casos`="days_gt_10",
`Dias depois de 100 Casos`="days_gt_100", `Casos Acumulados`="cases")),
shiny::selectInput("filter_cities", "Cidades", multiple = TRUE, choices = sort(unique(coronavirusbrazil::coronavirus_br_cities$city)), selected = c("Rio de Janeiro", "São Paulo")),
shiny::checkboxInput("log_scale_cities", "Escala Log", value = TRUE),
shiny::checkboxInput("log_scale_cities", "Escala Log", value = FALSE),
shiny::checkboxInput("facet_cities", "Gráficos Individuais", value = TRUE),
shiny::checkboxInput("linear_smooth_cities", "Tendência")
# shiny::checkboxInput("linear_smooth_cities", "Tendência")
),
shiny::mainPanel(
plotly::plotlyOutput("plot_cities")
Expand Down
7 changes: 5 additions & 2 deletions R/plot_covid.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ plot_coronavirus = function(coronavirus_br, xaxis="date", yaxis="cases",

if (is.null(color)){
g = df_ %>%
ggplot2::ggplot(ggplot2::aes_string(xaxis, yaxis)) + ggplot2::geom_point() +
dplyr::group_by(!!as.symbol(color)) %>%
dplyr::mutate(roll_mean=zoo::rollmean(!!as.symbol(yaxis), 7, na.pad = TRUE)) %>%
ggplot2::ggplot(ggplot2::aes_string(xaxis, yaxis)) + ggplot2::geom_point(alpha=0.5) + geom_line(aes(y=roll_mean), size=2) +
ggplot2::xlab(xaxis_label) + ggplot2::ylab(yaxis_label) + ggplot2::ylim(0, NA)
} else {
g = df_ %>%
ggplot2::ggplot(ggplot2::aes_string(xaxis, yaxis, color=color)) + ggplot2::geom_point() +
dplyr::mutate(roll_mean=zoo::rollmean(!!as.symbol(yaxis), 7, na.pad = TRUE)) %>%
ggplot2::ggplot(ggplot2::aes_string(xaxis, yaxis, color=color)) + ggplot2::geom_point(alpha=0.5) + geom_line(aes(y=roll_mean), size=2) +
ggplot2::xlab(xaxis_label) + ggplot2::ylab(yaxis_label) + ggplot2::ylim(0, NA) + ggplot2::scale_color_discrete(color_label)
}

Expand Down
1 change: 1 addition & 0 deletions app.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
pkgload::load_all(export_all = FALSE,helpers = FALSE,attach_testthat = FALSE)
options( "golem.app.prod" = TRUE)
coronavirusbrazil::run_app()
#
Binary file modified data/coronavirus_br.rda
Binary file not shown.
Binary file modified data/coronavirus_br_cities.rda
Binary file not shown.
Binary file modified data/coronavirus_br_states.rda
Binary file not shown.
Binary file modified data/coronavirus_rj_case_metadata.rda
Binary file not shown.
Binary file modified data/coronavirus_world.rda
Binary file not shown.
Binary file modified data/spatial_br_cities.rda
Binary file not shown.
Binary file modified data/spatial_br_states.rda
Binary file not shown.
Binary file modified data/spatial_rj_neighborhoods.rda
Binary file not shown.
Binary file modified data/spatial_world.rda
Binary file not shown.

0 comments on commit 9e0eeaf

Please sign in to comment.