Skip to content

Commit

Permalink
Added New Function Concern
Browse files Browse the repository at this point in the history
  • Loading branch information
lboullu committed May 6, 2020
1 parent 616cea2 commit 0289df0
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
62 changes: 62 additions & 0 deletions get_world_maps.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
library(dplyr)
library(maps)


get_world_map <- function(s){
world_map <- map_data(s)
world_map$country = world_map$region

world_map[world_map$region == "Grenadines","country"] <- "Saint Vincent and the Grenadines"
world_map[world_map$region == "Saint Vincent","country"] <- "Saint Vincent and the Grenadines"
world_map[world_map$region == "Antigua","country"] <- "Antigua and Barbuda"
world_map[world_map$region == "Barbuda","country"] <- "Antigua and Barbuda"

world_map[world_map$region == "Aruba","country"] <- "Netherlands"
world_map[world_map$region == "Curacao","country"] <- "Netherlands"
world_map[world_map$region == "Bonaire","country"] <- "Netherlands"
world_map[world_map$region == "Sint Eustatius","country"] <- "Netherlands"
world_map[world_map$region == "Saba","country"] <- "Netherlands"
world_map[world_map$region == "Sint Maarten","country"] <- "Netherlands"

world_map[world_map$region == "Anguilla","country"] <- "UK"
world_map[world_map$region == "Bermuda","country"] <- "UK"
world_map[world_map$region == "Falkland Islands","country"] <- "UK"
world_map[world_map$region == "Chagos Archipelago","country"] <- "UK"
world_map[world_map$region == "Pitcairn Islands","country"] <- "UK"
world_map[world_map$region == "South Sandwich Islands","country"] <- "UK"
world_map[world_map$region == "Saint Helena","country"] <- "UK"
world_map[world_map$region == "Ascension Island","country"] <- "UK"
world_map[world_map$region == "Turks and Caicos Islands","country"] <- "UK"

world_map[world_map$region == "French Southern and Antarctic Lands","country"] <- "France"
world_map[world_map$region == "Saint Barthelemy","country"] <- "France"
world_map[world_map$region == "Reunion","country"] <- "France"
world_map[world_map$region == "Mayotte","country"] <- "France"
world_map[world_map$region == "French Guiana","country"] <- "France"
world_map[world_map$region == "Martinique","country"] <- "France"
world_map[world_map$region == "Guadeloupe","country"] <- "France"
world_map[world_map$region == "Saint Martin","country"] <- "France"
world_map[world_map$region == "New Caledonia","country"] <- "France"
world_map[world_map$region == "French Polynesia","country"] <- "France"
world_map[world_map$region == "Saint Pierre and Miquelon","country"] <- "France"
world_map[world_map$region == "Wallis and Futuna","country"] <- "France"

world_map[world_map$region == "Canary Islands","country"] <- "Spain"
world_map[world_map$region == "Montserrat","country"] <- "Spain"

world_map[world_map$region == "Azores","country"] <- "Portugal"

world_map[world_map$region == "Guam","country"] <- "USA"
world_map[world_map$region == "Puerto Rico","country"] <- "USA"

world_map[world_map$region == "Heard Island","country"] <- "Australia"
world_map[world_map$region == "Cocos Islands","country"] <- "Australia"
world_map[world_map$region == "Christmas Island","country"] <- "Australia"
world_map[world_map$region == "Norfolk Island","country"] <- "Australia"

world_map[world_map$region == "Siachen Glacier","country"] <- "India"

world_map[world_map$region == "Trinidad","country"] <- "Trinidad and Tobago"
world_map[world_map$region == "Tobago","country"] <- "Trinidad and Tobago"
return(world_map)
}
10 changes: 8 additions & 2 deletions server.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
server <- function(input, output, session) {
# Loading Data ----
data <- read.csv("covid_06042020_choice_values.csv", header = T, stringsAsFactors = F)
data <- data[3:nrow(data),]

args <- commandArgs(TRUE)
args <- ifelse(length(args)==0,"../COVIDiSTRESS_April_27_clean.csv",args)
data = read.csv(args, header=T, stringsAsFactors=F)

data = data %>%
mutate(Country=recode(Country,"Cabo Verde"="Cape Verde","Congo, Democratic Republic of the"="Democratic Republic of the Congo","Congo, Republic of the"="Republic of Congo","Côte d’Ivoire"="Ivory Coast","East Timor (Timor-Leste)"="Timor-Leste","Korea, North"="North Korea","Korea, South"="South Korea","Micronesia, Federated States of"="Micronesia","Sudan, South"="South Sudan","The Bahamas"="Bahamas","United Kingdom"="UK","United States"="USA"))


# Creating Variables ----

Expand Down
1 change: 1 addition & 0 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ library(plotly)
library(dplyr)
library(stringr)
library(maps)
source("get_world_maps.R")

#### UI ----

Expand Down

0 comments on commit 0289df0

Please sign in to comment.