diff --git a/data-raw/AUS_CigTob_Exp/AUS_CigTob_Exp.R b/data-raw/AUS_CigTob_Exp/AUS_CigTob_Exp.R index 8127d08..ec23e70 100644 --- a/data-raw/AUS_CigTob_Exp/AUS_CigTob_Exp.R +++ b/data-raw/AUS_CigTob_Exp/AUS_CigTob_Exp.R @@ -7,7 +7,7 @@ library(fpp3) # for Victoria), and merged the respective cigarettes and tobacco expenditure # data into a single data set. -aus_tobacco <- readxl::read_xlsx(path ="data-raw/AUS_CigTob_Exp/CigTob_Updated.xlsx") |> +aus_tobacco <- readxl::read_xlsx(path = here::here("data-raw/AUS_CigTob_Exp/CigTob_Updated.xlsx")) |> mutate(Quarter = yearquarter(Quarter)) |> pivot_longer(VIC:ACT, names_to = "State", values_to = "Expenditure") |> mutate(Expenditure = Expenditure / 1e3) |> diff --git a/data-raw/AUS_Fertility/aus_fertility.R b/data-raw/AUS_Fertility/aus_fertility.R index ed5f375..a26eca0 100644 --- a/data-raw/AUS_Fertility/aus_fertility.R +++ b/data-raw/AUS_Fertility/aus_fertility.R @@ -3,7 +3,7 @@ library(fpp3) # Data downloaded from https://www.abs.gov.au/statistics/people/population/births-australia/2022 # Fertility, by age, by state of usual residence # on 30 May 2024 -aus_fertility <- readr::read_csv("data-raw/AUS_Fertility/ABS_FERTILITY_AGE_STATE_1.0.0_...A.csv") +aus_fertility <- readr::read_csv(here::here("data-raw/AUS_Fertility/ABS_FERTILITY_AGE_STATE_1.0.0_...A.csv")) aus_fertility <- aus_fertility |> filter(`MEASURE: Measure` == "11: Fertility rate") |> select(-c(DATAFLOW, `MEASURE: Measure`, `FREQ: Frequency`, `UNIT_MEASURE: Unit of Measure`, diff --git a/data-raw/AUS_accommodation/aus_accommodation.R b/data-raw/AUS_accommodation/aus_accommodation.R index 7afb222..a2e3fa2 100644 --- a/data-raw/AUS_accommodation/aus_accommodation.R +++ b/data-raw/AUS_accommodation/aus_accommodation.R @@ -1,8 +1,7 @@ -library(tsibble) -library(tidyverse) +library(fpp3) library(readabs) -aus_accommodation <- read_abs_local(filenames="8635010.xlsx", path="data-raw/AUS_accommodation/") |> +aus_accommodation <- read_abs_local(filenames="8635010.xlsx", path=here::here("data-raw/AUS_accommodation/")) |> filter(series_type == "Original") |> mutate( Date = yearquarter(date), @@ -20,7 +19,7 @@ aus_accommodation <- read_abs_local(filenames="8635010.xlsx", path="data-raw/AUS filter(State != "Total (Area)") |> as_tsibble(index=Date, key=State) -cpi <- read_abs_local(filenames="640101.xlsx", path="data-raw/AUS_accommodation/") |> +cpi <- read_abs_local(filenames="640101.xlsx", path=here::here("data-raw/AUS_accommodation/")) |> filter(str_detect(series,"Australia"), data_type=="INDEX") |> mutate(Date = yearquarter(date)) |> select(Date, value) |> diff --git a/data-raw/US_change/uschange.R b/data-raw/US_change/uschange.R index ea415ad..24f5727 100644 --- a/data-raw/US_change/uschange.R +++ b/data-raw/US_change/uschange.R @@ -5,7 +5,7 @@ library(tsibble) # Downloaded from https://research.stlouisfed.org/pdl/1216/ # Read monthly unemployment data -unrate <- read_tsv("data-raw/US_change/uschange_fpp3_Monthly.txt") |> +unrate <- read_tsv(here::here("data-raw/US_change/uschange_fpp3_Monthly.txt")) |> mutate(Month = yearmonth(observation_date)) |> select(Month, everything(), -observation_date) |> rename(Unemployment = UNRATE_20191004) |> @@ -19,7 +19,7 @@ unrate <- unrate |> filter_index("1969 Q4" ~ .) # Read remaining quarterly data -other <- read_tsv("data-raw/US_change/uschange_fpp3_Quarterly.txt", na=c("",".")) |> +other <- read_tsv(here::here("data-raw/US_change/uschange_fpp3_Quarterly.txt"), na=c("",".")) |> mutate(Quarter = yearquarter(observation_date)) |> select(Quarter, everything(), -observation_date) |> rename( diff --git a/data-raw/US_employment/US_employment.R b/data-raw/US_employment/US_employment.R index e5c6d5f..515def6 100644 --- a/data-raw/US_employment/US_employment.R +++ b/data-raw/US_employment/US_employment.R @@ -5,7 +5,7 @@ library(tsibble) # Data download from https://research.stlouisfed.org/pdl/1215 us_employment <- read_tsv( - "data-raw/US_employment/US_employment_fpp3_Monthly.txt", + here::here("data-raw/US_employment/US_employment_fpp3_Monthly.txt"), col_types = cols( .default = col_double(), observation_date = col_date(format = "") @@ -16,7 +16,7 @@ us_employment <- read_tsv( separate(Series_ID, "Series_ID", extra = "drop") |> as_tsibble(key = Series_ID, index=Month) -readme <- read_lines("data-raw/US_employment/US_employment_fpp3_README.txt") |> +readme <- read_lines(here::here("data-raw/US_employment/US_employment_fpp3_README.txt")) |> {split(., cumsum(str_detect(., "Series ID")))[-1]} |> map_dfr(function(desc){ desc <- desc[seq_len(str_which(desc, "The source code is") - 1)]