Skip to content

Commit

Permalink
Use here::here when reading data-raw files
Browse files Browse the repository at this point in the history
  • Loading branch information
robjhyndman committed Jun 25, 2024
1 parent 849cece commit 95c968a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion data-raw/AUS_CigTob_Exp/AUS_CigTob_Exp.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) |>
Expand Down
2 changes: 1 addition & 1 deletion data-raw/AUS_Fertility/aus_fertility.R
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
7 changes: 3 additions & 4 deletions data-raw/AUS_accommodation/aus_accommodation.R
Original file line number Diff line number Diff line change
@@ -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),
Expand All @@ -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) |>
Expand Down
4 changes: 2 additions & 2 deletions data-raw/US_change/uschange.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) |>
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions data-raw/US_employment/US_employment.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "")
Expand All @@ -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)]
Expand Down

0 comments on commit 95c968a

Please sign in to comment.