Skip to content

Commit

Permalink
changes 09/10
Browse files Browse the repository at this point in the history
- I added a “the” for "USA", "GBR", "CZE", "SVK", "NLD" in the file fig3_text_FINAL.xlsx
- Canada, Chile, Ireland and Mexico I made sure figures are using the most update sources (countryprofile_fig3_alt.xlsx and countryprofile_fig4_alt.xlsx)
  • Loading branch information
Taina.SOUZAPACHECO committed Oct 9, 2023
1 parent b793d0a commit 800b50c
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 138 deletions.
Binary file modified data/fig3_text_FINAL.xlsx
Binary file not shown.
48 changes: 24 additions & 24 deletions tl0-irl.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,25 @@ read_html_table(ctry)

```{r fig3}
# read ----
finp <- if (any(ctry %in% c("AUS", "CAN", "COL", "CHE", "CHL", "IRL", "MEX"))) {
"data/countryprofile_option1_addon.xlsx"
} else {
"data/countryprofile_option1.xlsx"
}
dp1 <- read_excel(finp, sheet = ctry) %>%
#
# finp <- if (any(ctry %in% c("AUS", "CAN", "COL", "CHE", "CHL", "IRL", "MEX"))) {
# "data/countryprofile_option1_addon.xlsx"
# } else {
# "data/countryprofile_option1.xlsx"
# }
#
# dp1 <- read_excel(finp, sheet = ctry) %>%
# clean_names()
#
# # tidy ----
#
# colnames(dp1) <- str_replace(colnames(dp1), tolower(ctry), "country")
dp1 <- read_excel("data/countryprofile_fig3_alt.xlsx", sheet = ctry) %>%
select(time, pw_lp, pw_hp) %>%
clean_names()
# tidy ----
colnames(dp1) <- str_replace(colnames(dp1), tolower(ctry), "country")
colnames(dp1) <- c("time", "pw_lp_country", "pw_hp_country")
dp11 <- dp1 %>%
select(time, matches("country")) %>%
Expand Down Expand Up @@ -154,28 +160,24 @@ ggplotly(fig3_1) %>%

```{r fig4}
# read ----
# %%%% WE NEED THIS FILE AND NOT countryprofile_fig3_alt.xlsx WITH 2 CATEGORIES %%%%
dp2 <- read_excel("data/countryprofile_option2_addon.xlsx", sheet = ctry) %>%
dp2 <- read_excel("data/countryprofile_fig4_alt.xlsx", sheet = ctry) %>%
clean_names()
# tidy ----
colnames(dp2) <- str_replace(colnames(dp2), tolower(ctry), "country")
# colnames(dp2) <- c("time", "pw_lp_country", "pw_hp_country")
dp21 <- dp2 %>%
select(time, matches("country")) %>%
select(time, starts_with("share_")) %>%
pivot_longer(-time) %>%
rename(value_country = value)
dp21 <- dp21 %>%
mutate(
name = case_when(
name == "share_tgoods_lp_country" ~ paste(ctry, "TG LP"),
name == "share_tgoods_hp_country" ~ paste(ctry, "TG HP"),
name == "share_tserv_lp_country" ~ paste(ctry, "TS LP"),
name == "share_tserv_hp_country" ~ paste(ctry, "TS HP")
name == "share_tgoods_lp" ~ paste(ctry, "TG LP"),
name == "share_tgoods_hp" ~ paste(ctry, "TG HP"),
name == "share_tserv_lp" ~ paste(ctry, "TS LP"),
name == "share_tserv_hp" ~ paste(ctry, "TS HP")
)
)
Expand Down Expand Up @@ -257,8 +259,6 @@ dp21_2 <- dp21 %>%
category2 = str_replace_all(category2, as.character(min(yrs)), "minyr"),
category2 = str_replace_all(category2, as.character(max(yrs)), "maxyr")
) %>%
# remove all after productivy in category2
# mutate(category2 = str_replace_all(category2, "productivity.*", "productivity")) %>%
pivot_wider(names_from = category2, values_from = value_country) %>%
clean_names()
Expand Down
146 changes: 74 additions & 72 deletions tl2-can.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -328,18 +328,24 @@ ggplotly(fig1) %>%
```{r can_fig2}
# read ----
finp <- if (any(ctry %in% c("AUS", "CAN", "COL", "CHE", "CHL", "IRL", "MEX"))) {
"data/countryprofile_option1_addon.xlsx"
} else {
"data/countryprofile_option1.xlsx"
}
dp1 <- read_excel(finp, sheet = ctry) %>%
# finp <- if (any(ctry %in% c("AUS", "CAN", "COL", "CHE", "CHL", "IRL", "MEX"))) {
# "data/countryprofile_option1_addon.xlsx"
# } else {
# "data/countryprofile_option1.xlsx"
# }
#
# dp1 <- read_excel(finp, sheet = ctry) %>%
# clean_names()
#
# # tidy ----
#
# colnames(dp1) <- str_replace(colnames(dp1), tolower(ctry), "country")
dp1 <- read_excel("data/countryprofile_fig3_alt.xlsx", sheet = ctry) %>%
select(time, pw_lp, pw_hp) %>%
clean_names()
# tidy ----
colnames(dp1) <- str_replace(colnames(dp1), tolower(ctry), "country")
colnames(dp1) <- c("time", "pw_lp_country", "pw_hp_country")
dp11 <- dp1 %>%
select(time, matches("country")) %>%
Expand Down Expand Up @@ -440,28 +446,24 @@ ggplotly(fig2) %>%

```{r can_fig3}
# read ----
# %%%% WE NEED THIS FILE AND NOT countryprofile_fig3_alt.xlsx WITH 2 CATEGORIES %%%%
dp2 <- read_excel("data/countryprofile_option2_addon.xlsx", sheet = ctry) %>%
dp2 <- read_excel("data/countryprofile_fig4_alt.xlsx", sheet = ctry) %>%
clean_names()
# tidy ----
colnames(dp2) <- str_replace(colnames(dp2), tolower(ctry), "country")
# colnames(dp2) <- c("time", "pw_lp_country", "pw_hp_country")
dp21 <- dp2 %>%
select(time, matches("country")) %>%
select(time, starts_with("share_")) %>%
pivot_longer(-time) %>%
rename(value_country = value)
dp21 <- dp21 %>%
mutate(
name = case_when(
name == "share_tgoods_lp_country" ~ paste(ctry, "TG LP"),
name == "share_tgoods_hp_country" ~ paste(ctry, "TG HP"),
name == "share_tserv_lp_country" ~ paste(ctry, "TS LP"),
name == "share_tserv_hp_country" ~ paste(ctry, "TS HP")
name == "share_tgoods_lp" ~ paste(ctry, "TG LP"),
name == "share_tgoods_hp" ~ paste(ctry, "TG HP"),
name == "share_tserv_lp" ~ paste(ctry, "TS LP"),
name == "share_tserv_hp" ~ paste(ctry, "TS HP")
)
)
Expand All @@ -470,57 +472,57 @@ dp21 <- dp21 %>%
yrs <- sort(unique(dp21$time))
yrs <- seq(min(yrs), max(yrs), 1)
# tghpgrew <- dp21 %>%
# filter(
# name == paste(ctry, "TG HP"),
# time %in% c(min(yrs), max(yrs))
# ) %>%
# summarise(grew = value_country - lag(value_country)) %>%
# drop_na() %>%
# pull() %>%
# round(1)
# tglpgrew <- dp21 %>%
# filter(
# name == paste(ctry, "TG LP"),
# time %in% c(min(yrs), max(yrs))
# ) %>%
# summarise(grew = value_country - lag(value_country)) %>%
# drop_na() %>%
# pull() %>%
# round(1)
# tghpdiff <- tghpgrew - tglpgrew
# tghpmore <- ifelse(tghpdiff > 0, "grew", "declined")
# tglpdiff <- tglpgrew - tglpgrew
# tglpmore <- ifelse(tglpdiff > 0, "grew", "declined")
# tshpgrew <- dp21 %>%
# filter(
# name == paste(ctry, "TS HP"),
# time %in% c(min(yrs), max(yrs))
# ) %>%
# summarise(grew = value_country - lag(value_country)) %>%
# drop_na() %>%
# pull() %>%
# round(1)
# tslpgrew <- dp21 %>%
# filter(
# name == paste(ctry, "TS LP"),
# time %in% c(min(yrs), max(yrs))
# ) %>%
# summarise(grew = value_country - lag(value_country)) %>%
# drop_na() %>%
# pull() %>%
# round(1)
# tshpdiff <- tshpgrew - tslpgrew
# tshpmore <- ifelse(tshpdiff > 0, "grew", "declined")
# tslpdiff <- tslpgrew - tslpgrew
# tslpmore <- ifelse(tslpdiff > 0, "grew", "declined")
tghpgrew <- dp21 %>%
filter(
name == paste(ctry, "TG HP"),
time %in% c(min(yrs), max(yrs))
) %>%
summarise(grew = value_country - lag(value_country)) %>%
drop_na() %>%
pull() %>%
round(1)
tglpgrew <- dp21 %>%
filter(
name == paste(ctry, "TG LP"),
time %in% c(min(yrs), max(yrs))
) %>%
summarise(grew = value_country - lag(value_country)) %>%
drop_na() %>%
pull() %>%
round(1)
tghpdiff <- tghpgrew - tglpgrew
tghpmore <- ifelse(tghpdiff > 0, "grew", "declined")
tglpdiff <- tglpgrew - tglpgrew
tglpmore <- ifelse(tglpdiff > 0, "grew", "declined")
tshpgrew <- dp21 %>%
filter(
name == paste(ctry, "TS HP"),
time %in% c(min(yrs), max(yrs))
) %>%
summarise(grew = value_country - lag(value_country)) %>%
drop_na() %>%
pull() %>%
round(1)
tslpgrew <- dp21 %>%
filter(
name == paste(ctry, "TS LP"),
time %in% c(min(yrs), max(yrs))
) %>%
summarise(grew = value_country - lag(value_country)) %>%
drop_na() %>%
pull() %>%
round(1)
tshpdiff <- tshpgrew - tslpgrew
tshpmore <- ifelse(tshpdiff > 0, "grew", "declined")
tslpdiff <- tslpgrew - tslpgrew
tslpmore <- ifelse(tslpdiff > 0, "grew", "declined")
dp21 <- dp21 %>%
mutate(category = gsub(paste0("^OECD |^", ctry, " "), "", name))
Expand Down
50 changes: 25 additions & 25 deletions tl2-chl.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -329,19 +329,25 @@ ggplotly(fig1) %>%

```{r chl_fig2}
# read ----
finp <- if (any(ctry %in% c("AUS", "CAN", "COL", "CHE", "CHL", "IRL", "MEX"))) {
"data/countryprofile_option1_addon.xlsx"
} else {
"data/countryprofile_option1.xlsx"
}
dp1 <- read_excel(finp, sheet = ctry) %>%
#
# finp <- if (any(ctry %in% c("AUS", "CAN", "COL", "CHE", "CHL", "IRL", "MEX"))) {
# "data/countryprofile_option1_addon.xlsx"
# } else {
# "data/countryprofile_option1.xlsx"
# }
#
# dp1 <- read_excel(finp, sheet = ctry) %>%
# clean_names()
#
# # tidy ----
#
# colnames(dp1) <- str_replace(colnames(dp1), tolower(ctry), "country")
dp1 <- read_excel("data/countryprofile_fig3_alt.xlsx", sheet = ctry) %>%
select(time, pw_lp, pw_hp) %>%
clean_names()
# tidy ----
colnames(dp1) <- str_replace(colnames(dp1), tolower(ctry), "country")
colnames(dp1) <- c("time", "pw_lp_country", "pw_hp_country")
dp11 <- dp1 %>%
select(time, matches("country")) %>%
Expand Down Expand Up @@ -442,30 +448,26 @@ ggplotly(fig2) %>%
<br>
<br>

```{r chl_fig3}
```{r fig4}
# read ----
# %%%% WE NEED THIS FILE AND NOT countryprofile_fig3_alt.xlsx WITH 2 CATEGORIES %%%%
dp2 <- read_excel("data/countryprofile_option2_addon.xlsx", sheet = ctry) %>%
dp2 <- read_excel("data/countryprofile_fig4_alt.xlsx", sheet = ctry) %>%
clean_names()
# tidy ----
colnames(dp2) <- str_replace(colnames(dp2), tolower(ctry), "country")
# colnames(dp2) <- c("time", "pw_lp_country", "pw_hp_country")
dp21 <- dp2 %>%
select(time, matches("country")) %>%
select(time, starts_with("share_")) %>%
pivot_longer(-time) %>%
rename(value_country = value)
dp21 <- dp21 %>%
mutate(
name = case_when(
name == "share_tgoods_lp_country" ~ paste(ctry, "TG LP"),
name == "share_tgoods_hp_country" ~ paste(ctry, "TG HP"),
name == "share_tserv_lp_country" ~ paste(ctry, "TS LP"),
name == "share_tserv_hp_country" ~ paste(ctry, "TS HP")
name == "share_tgoods_lp" ~ paste(ctry, "TG LP"),
name == "share_tgoods_hp" ~ paste(ctry, "TG HP"),
name == "share_tserv_lp" ~ paste(ctry, "TS LP"),
name == "share_tserv_hp" ~ paste(ctry, "TS HP")
)
)
Expand Down Expand Up @@ -547,8 +549,6 @@ dp21_2 <- dp21 %>%
category2 = str_replace_all(category2, as.character(min(yrs)), "minyr"),
category2 = str_replace_all(category2, as.character(max(yrs)), "maxyr")
) %>%
# remove all after productivy in category2
# mutate(category2 = str_replace_all(category2, "productivity.*", "productivity")) %>%
pivot_wider(names_from = category2, values_from = value_country) %>%
clean_names()
Expand Down
24 changes: 7 additions & 17 deletions tl2-mex.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -437,34 +437,26 @@ ggplotly(fig2) %>%
<br>
<br>

```{r mex_fig3}
```{r fig4}
# read ----
finp <- if (any(ctry %in% c("AUS", "CAN", "COL", "CHE", "CHL", "IRL", "MEX"))) {
"data/countryprofile_option2_addon.xlsx"
} else {
"data/countryprofile_option2.xlsx"
}
dp2 <- read_excel(finp, sheet = ctry) %>%
dp2 <- read_excel("data/countryprofile_fig4_alt.xlsx", sheet = ctry) %>%
clean_names()
# tidy ----
colnames(dp2) <- str_replace(colnames(dp2), tolower(ctry), "country")
dp21 <- dp2 %>%
select(time, matches("country")) %>%
select(time, starts_with("share_")) %>%
pivot_longer(-time) %>%
rename(value_country = value)
dp21 <- dp21 %>%
mutate(
name = case_when(
name == "share_tgoods_lp_country" ~ paste(ctry, "TG LP"),
name == "share_tgoods_hp_country" ~ paste(ctry, "TG HP"),
name == "share_tserv_lp_country" ~ paste(ctry, "TS LP"),
name == "share_tserv_hp_country" ~ paste(ctry, "TS HP")
name == "share_tgoods_lp" ~ paste(ctry, "TG LP"),
name == "share_tgoods_hp" ~ paste(ctry, "TG HP"),
name == "share_tserv_lp" ~ paste(ctry, "TS LP"),
name == "share_tserv_hp" ~ paste(ctry, "TS HP")
)
)
Expand Down Expand Up @@ -546,8 +538,6 @@ dp21_2 <- dp21 %>%
category2 = str_replace_all(category2, as.character(min(yrs)), "minyr"),
category2 = str_replace_all(category2, as.character(max(yrs)), "maxyr")
) %>%
# remove all after productivy in category2
# mutate(category2 = str_replace_all(category2, "productivity.*", "productivity")) %>%
pivot_wider(names_from = category2, values_from = value_country) %>%
clean_names()
Expand Down

0 comments on commit 800b50c

Please sign in to comment.