Last active
January 24, 2021 19:04
-
-
Save rrodrigueznt/550f9ef6a863e5515b7ad016f316d115 to your computer and use it in GitHub Desktop.
This file contains 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
# | |
options(stringsAsFactors=F) | |
options(digits=2) | |
# | |
# | |
# returns string w/o leading whitespace | |
trim.leading <- function (x) sub("^\\s+", "", x) | |
# | |
# returns string w/o trailing whitespace | |
trim.trailing <- function (x) sub("\\s+$", "", x) | |
# | |
# returns string w/o leading or trailing whitespace | |
trim <- function (x) gsub("^\\s+|\\s+$", "", x) | |
# | |
# | |
library(openxlsx) #to use read.xlsx() | |
library(readxl) #to read Excel's sheets names and *.xls files | |
library(dplyr) #to filter, order, rarrange... | |
# | |
## | |
## https://www.sharpsightlabs.com/blog/map-oil-production-country-r/ | |
## as an example for creating maps | |
## | |
library(tidyverse) | |
library(sf) | |
library(rvest) | |
library(stringr) | |
library(scales) | |
library(maps) | |
# | |
map.world <- map_data('world') | |
# | |
#IGFAEQCD <- file.path("/Users/rrodriguez/Universidade de Santiago de Compostela/SALGADO LOPEZ CARLOS ALBERTO - IGFAE/GlobalTalent/IGFAEGlobalTalent2018/IGFAEQCD.appl.csv") | |
#IGFAEQCD <- file.path("C:/Users/Ricardo Rodríguez/Universidade de Santiago de Compostela/IGFAE-EB - Documents/0001.HumanCapital/Internal_postdoc/2018/MdM_QCD/appl-Original.xls") | |
IGFAEQCD <- file.path("C:/Users/ricar/Universidade de Santiago de Compostela/IGFAE-EB - Documents/HumanCapital/Scouting/MdM_QCD/appl-Original.xls") | |
# | |
IGFAEQCDdata <- readxl::read_excel(IGFAEQCD, sheet = "ajo154590681752867") | |
# | |
IGFAEQCDdata$LastUpdated <- as.Date(IGFAEQCDdata$LastUpdated) | |
IGFAEQCDdata$Received <- as.Date(IGFAEQCDdata$Received) | |
# | |
IGFAEQCDdata[,c('Uid','Name','Degree_Institution')] | |
# | |
as.data.frame(IGFAEQCDdata[,c('Uid')]) | |
# | |
#AJO <- file.path("/Users/rrodriguez/Universidade de Santiago de Compostela/SALGADO LOPEZ CARLOS ALBERTO - IGFAE/GlobalTalent/IGFAEGlobalTalent2018/AJOuid.xlsx") | |
AJO <- file.path("C:/Users/Ricardo Rodríguez/Universidade de Santiago de Compostela/IGFAE-EB - Documents/0002.GlobalTalent/IGFAEGlobalTalent2018/AJOuid.xlsx") | |
# | |
AJOdata <- openxlsx::read.xlsx(AJO, sheet = "people") | |
# | |
IGFAEQCDdataAll <- merge(IGFAEQCDdata, AJOdata) | |
# | |
table(IGFAEQCDdataAll$gender) | |
# | |
prop.table(table(IGFAEQCDdataAll$gender)) | |
# | |
anti_join(IGFAEQCDdataAll, map.world, by = c('countryDegree' = 'region')) | |
# | |
IGFAEQCDbyCountry <- as.data.frame(table(IGFAEQCDdataAll$countryDegree), stringsAsFactors = default.stringsAsFactors()) | |
# | |
names(IGFAEQCDbyCountry) <- c('countryDegree','nApplications') | |
# | |
map.IGFAEQCD <- left_join(map.world, IGFAEQCDbyCountry, by = c('region' = 'countryDegree')) | |
# | |
anti_join(IGFAEQCDbyCountry, map.world, by = c('countryDegree' = 'region')) | |
# | |
ggplot(map.IGFAEQCD, aes( x = long, y = lat, group = group )) + geom_polygon(aes(fill = nApplications)) | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment