Skip to content

Commit

Permalink
More consistent naming of data sets
Browse files Browse the repository at this point in the history
  • Loading branch information
robjhyndman committed Jun 25, 2024
1 parent c064463 commit 04233f6
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 64 deletions.
8 changes: 4 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# fpp3 (development version)
* Many more data sets added:
- aus_births
- aus_cigtob
- aus_fertility
- aus_inbound
- aus_mortality
- aus_nom
- aus_migration
- aus_outbound
- aus_tobacco
- aus_vehicle_sales
- daily_walkers
- melb_walkers
- nsw_offences
- ny_childcare
- offences
- otexts_views

# fpp3 (0.5)
Expand Down
29 changes: 12 additions & 17 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,13 @@ NULL
#' @keywords datasets
#'
#' @examples
#' library(tsibble)
#' aus_fertility
#'
NULL

#' Monthly offences in NSW
#'
#' \code{offences} is a monthly `tsibble` with one measured variable:
#' \code{nsw_offences} is a monthly `tsibble` with one measured variable:
#' \tabular{ll}{
#' Count: \tab Number of offences reported \cr
#' }
Expand All @@ -276,14 +275,13 @@ NULL
#' @source NSW Bureau of Crime Statistics and Research. <https://www.bocsar.nsw.gov.au/Pages/bocsar_datasets/Offence.aspx>
#'
#'
#' @name offences
#' @name nsw_offences
#' @docType data
#' @format Time series of class `tsibble`
#' @keywords datasets
#'
#' @examples
#' library(tsibble)
#' offences
#' nsw_offences
#'
NULL

Expand All @@ -295,14 +293,13 @@ NULL
#' @source Melbourne Open Data Portal. <https://data.melbourne.vic.gov.au/>
#'
#'
#' @name daily_walkers
#' @name melb_walkers
#' @docType data
#' @format Time series of class `tsibble`
#' @keywords datasets
#'
#' @examples
#' library(tsibble)
#' daily_walkers
#' autoplot(melb_walkers)
#'
NULL

Expand Down Expand Up @@ -330,7 +327,6 @@ NULL
#' @keywords datasets
#'
#' @examples
#' library(tsibble)
#' aus_inbound
#'
NULL
Expand Down Expand Up @@ -359,7 +355,6 @@ NULL
#' @keywords datasets
#'
#' @examples
#' library(tsibble)
#' aus_outbound
#'
NULL
Expand Down Expand Up @@ -451,7 +446,7 @@ NULL
#'
#' Net Overseas Migration (NOM) to Australia.
#'
#' \code{aus_nom} is a quarterly `tsibble` with one measured variable:
#' \code{aus_migration} is a quarterly `tsibble` with one measured variable:
#' \tabular{ll}{
#' \code{NOM}: \tab The net gain or loss of population through immigration
#' to Australia and emigration from Australia\cr
Expand All @@ -471,13 +466,13 @@ NULL
#'
#' @source Australian Bureau of Statistics. <https://www.abs.gov.au/statistics/people/population/national-state-and-territory-population/dec-2023>. Cat No. 310102.
#'
#' @name aus_nom
#' @name aus_migration
#' @docType data
#' @format Time series of class `tsibble`
#' @keywords datasets
#' @examples
#'
#' aus_nom
#' aus_migration
#'
NULL

Expand All @@ -486,7 +481,7 @@ NULL
#' The total household expenditure for cigarette and tobacco consumption (CTC)
#' in Australia.
#'
#' \code{aus_cigtob} is a quarterly `tsibble` with one value:
#' \code{aus_tobacco} is a quarterly `tsibble` with one value:
#' \tabular{ll}{
#' \code{Expenditure}: \tab The total expenditure\cr
#' }
Expand All @@ -503,15 +498,15 @@ NULL
#' \code{State}: The state or territory.\cr
#' }
#'
#' @source Australian Bureau of Statistics
#' @source Australian Bureau of Statistics. <https://www.abs.gov.au/statistics/economy/national-accounts/australian-national-accounts-national-income-expenditure-and-product/mar-2024>
#'
#' @name aus_cigtob
#' @name aus_tobacco
#' @docType data
#' @format Time series of class `tsibble`
#' @keywords datasets
#' @examples
#'
#' aus_cigtob
#' aus_tobacco |> autoplot(Expenditure) + scale_y_log10()
#'
NULL

Expand Down
10 changes: 5 additions & 5 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
url: https://pkg.robjhyndman.com/fpp3package/
url: https://pkg.robjhyndman.com/fpp3package
template:
bootstrap: 5
theme: tango
Expand Down Expand Up @@ -33,21 +33,21 @@ reference:
- aus_accommodation
- aus_arrivals
- aus_births
- aus_cigtob
- aus_fertility
- aus_inbound
- aus_migration
- aus_mortality
- aus_nom
- aus_outbound
- aus_tobacco
- aus_vehicle_sales
- bank_calls
- boston_marathon
- canadian_gas
- daily_walkers
- guinea_rice
- insurance
- melb_walkers
- nsw_offences
- ny_childcare
- offences
- otexts_views
- prices
- souvenirs
Expand Down
13 changes: 9 additions & 4 deletions data-raw/Exams/AUS_CigTob_Exp/AUS_CigTob_Exp.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
library(fpp3)

# Data download from?????
# Data from
# https://www.abs.gov.au/statistics/economy/national-accounts/australian-national-accounts-national-income-expenditure-and-product/mar-2024
# We downloaded the data files for each state separately
# (For example "Table 27. State Final Demand, Detailed Components: Victoria"
# for Victoria), and merged the respective cigarettes and tobacco expenditure
# data into a single data set.

aus_cigtob <- readxl::read_xlsx(path ="data-raw/Exams/AUS_CigTob_Exp/CigTob_Updated.xlsx") |>
aus_tobacco <- readxl::read_xlsx(path ="data-raw/Exams/AUS_CigTob_Exp/CigTob_Updated.xlsx") |>
mutate(Quarter = yearquarter(Quarter)) |>
pivot_longer(VIC:ACT, names_to = "State", values_to = "Expenditure") |>
mutate(Expenditure = Expenditure / 1e3) |>
as_tsibble(index = Quarter, key = State)

#aus_cigtob |> autoplot(Expenditure) + scale_y_log10()
usethis::use_data(aus_cigtob, overwrite=TRUE)
#aus_tobacco |> autoplot(Expenditure) + scale_y_log10()
usethis::use_data(aus_tobacco, overwrite=TRUE)
6 changes: 3 additions & 3 deletions data-raw/Exams/AUS_NOM/AUS_NOM.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ library(fpp3)

# Data downloaded from https://www.abs.gov.au/statistics/people/population/national-state-and-territory-population/
# on 30 May 2024
aus_nom <- readxl::read_xlsx(path = here::here("data-raw/Exams/AUS_NOM/migration_updated.xlsx"))[1:10] |>
aus_migration <- readxl::read_xlsx(path = here::here("data-raw/Exams/AUS_NOM/migration_updated.xlsx"))[1:10] |>
mutate(Quarter = yearquarter(Date)) |>
pivot_longer(NSW:AUS, names_to = "State", values_to = "NOM") |>
select(Quarter, State, NOM) |>
as_tsibble(index = Quarter, key = State) |>
filter(State != "AUS")

#aus_nom |> autoplot()
usethis::use_data(aus_nom, overwrite=TRUE)
#aus_migration |> autoplot()
usethis::use_data(aus_migration, overwrite=TRUE)
10 changes: 5 additions & 5 deletions data-raw/Exams/Melb_Walk/melb_walk.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ start <- as.Date("2019-01-01")
end <- as.Date("2024-05-29")
pedestrian <- melb_walk(from = start, to = end, na.rm = FALSE, session = NULL)

daily_walkers <- pedestrian |>
melb_walkers <- pedestrian |>
mutate(Count = as.numeric(Count)) |>
group_by(Date, Sensor) |>
summarise(Count = sum(Count, na.rm=TRUE)) |>
Expand All @@ -14,21 +14,21 @@ daily_walkers <- pedestrian |>
as_tsibble(index = Date, key = Sensor)

# Remove censors with large numbers of missing values
nmiss <- daily_walkers |>
nmiss <- melb_walkers |>
as_tibble() |>
group_by(Sensor) |>
summarise(nmiss = sum(is.na(Count))) |>
filter(nmiss < 10)

# Interpolate missing values
daily_walkers <- daily_walkers |>
melb_walkers <- melb_walkers |>
filter(Sensor %in% nmiss$Sensor) |>
mutate(Count = zoo::na.approx(Count))

daily_walkers <- daily_walkers |>
melb_walkers <- melb_walkers |>
as_tibble() |>
group_by(Date) |>
summarise(Count = mean(Count)/1e3) |>
as_tsibble(index = Date)

usethis::use_data(daily_walkers, overwrite=TRUE)
usethis::use_data(melb_walkers, overwrite=TRUE)
6 changes: 3 additions & 3 deletions data-raw/Exams/NSW_Offence/offence.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ library(fpp3)

# Data downloaded from https://www.bocsar.nsw.gov.au/Pages/bocsar_datasets/Offence.aspx

offences <- readr::read_csv("data-raw/Exams/NSW_Offence/RCI_offencebymonth.csv")
nsw_offences <- readr::read_csv("data-raw/Exams/NSW_Offence/RCI_offencebymonth.csv")

offences <- offences |>
nsw_offences <- nsw_offences |>
pivot_longer(-(1:3), names_to = "Month", values_to = "Count") |>
rename(Type = `Offence category`) |>
group_by(Type, Month) |>
Expand All @@ -15,5 +15,5 @@ offences <- offences |>
ungroup() |>
tsibble(index = Month, key = Type)

usethis::use_data(offences, overwrite=TRUE)
usethis::use_data(nsw_offences, overwrite=TRUE)

Binary file removed data/aus_cigtob.rda
Binary file not shown.
Binary file added data/aus_migration.rda
Binary file not shown.
Binary file removed data/aus_nom.rda
Binary file not shown.
Binary file added data/aus_tobacco.rda
Binary file not shown.
Binary file removed data/daily_walkers.rda
Binary file not shown.
Binary file added data/melb_walkers.rda
Binary file not shown.
Binary file added data/nsw_offences.rda
Binary file not shown.
Binary file removed data/offences.rda
Binary file not shown.
1 change: 0 additions & 1 deletion man/aus_fertility.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/aus_inbound.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/aus_nom.Rd → man/aus_migration.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/aus_outbound.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/aus_cigtob.Rd → man/aus_tobacco.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/fpp3-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions man/daily_walkers.Rd → man/melb_walkers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 04233f6

Please sign in to comment.