Skip to content

Commit

Permalink
Fixed build_vital_fable arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
robjhyndman committed Jun 11, 2024
1 parent 1ba74e5 commit 00956d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 56 deletions.
66 changes: 11 additions & 55 deletions R/dplyr-verbs-fable.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ arrange.fbl_vtl_ts <- function(.data, ...) {
build_vital_fable(NextMethod(),
response = attr_data$response,
distribution = attr_data$dist,
.age = vvar$age,
.sex = vvar$sex,
.deaths = vvar$deaths,
.births = vvar$births,
.population = vvar$population
vitals = vvar
)
}

Expand All @@ -24,11 +20,7 @@ select.fbl_vtl_ts <- function(.data, ...) {
build_vital_fable(NextMethod(),
response = attr_data$response,
distribution = attr_data$dist,
.age = vvar$age,
.sex = vvar$sex,
.deaths = vvar$deaths,
.births = vvar$births,
.population = vvar$population
vitals = vvar
)
}

Expand All @@ -39,11 +31,7 @@ transmute.fbl_vtl_ts <- function(.data, ...) {
build_vital_fable(NextMethod(),
response = attr_data$response,
distribution = attr_data$dist,
.age = vvar$age,
.sex = vvar$sex,
.deaths = vvar$deaths,
.births = vvar$births,
.population = vvar$population
vitals = vvar
)
}

Expand All @@ -54,11 +42,7 @@ relocate.fbl_vtl_ts <- function(.data, ...) {
build_vital_fable(NextMethod(),
response = attr_data$response,
distribution = attr_data$dist,
.age = vvar$age,
.sex = vvar$sex,
.deaths = vvar$deaths,
.births = vvar$births,
.population = vvar$population
vitals = vvar
)
}

Expand All @@ -69,11 +53,7 @@ summarise.fbl_vtl_ts <- function(.data, ..., .groups = NULL) {
build_vital_fable(NextMethod(),
response = attr_data$response,
distribution = attr_data$dist,
.age = vvar$age,
.sex = vvar$sex,
.deaths = vvar$deaths,
.births = vvar$births,
.population = vvar$population
vitals = vvar
)
}

Expand All @@ -84,11 +64,7 @@ dplyr_row_slice.fbl_vtl_ts <- function(data, i, ..., preserve = FALSE) {
build_vital_fable(NextMethod(),
response = attr_data$response,
distribution = attr_data$dist,
.age = vvar$age,
.sex = vvar$sex,
.deaths = vvar$deaths,
.births = vvar$births,
.population = vvar$population
vitals = vvar
)
}

Expand All @@ -99,11 +75,7 @@ dplyr_col_modify.fbl_vtl_ts <- function(data, cols) {
build_vital_fable(NextMethod(),
response = attr_data$response,
distribution = attr_data$dist,
.age = vvar$age,
.sex = vvar$sex,
.deaths = vvar$deaths,
.births = vvar$births,
.population = vvar$population
vitals = vvar
)
}

Expand All @@ -114,11 +86,7 @@ dplyr_reconstruct.fbl_vtl_ts <- function(data, template) {
build_vital_fable(NextMethod(),
response = attr_data$response,
distribution = attr_data$dist,
.age = vvar$age,
.sex = vvar$sex,
.deaths = vvar$deaths,
.births = vvar$births,
.population = vvar$population
vitals = vvar
)
}

Expand All @@ -130,11 +98,7 @@ group_by.fbl_vtl_ts <- function(.data, ..., .add = FALSE,
tmp <- build_vital_fable(NextMethod(),
response = attr_data$response,
distribution = attr_data$dist,
.age = vvar$age,
.sex = vvar$sex,
.deaths = vvar$deaths,
.births = vvar$births,
.population = vvar$population
vitals = vvar
)
tmp_class <- class(tmp)
grouped_classes <- grepl("grouped", tmp_class)
Expand All @@ -149,11 +113,7 @@ ungroup.grouped_vital <- function(x, ...) {
build_vital_fable(NextMethod(),
response = attr_data$response,
distribution = attr_data$dist,
.age = vvar$age,
.sex = vvar$sex,
.deaths = vvar$deaths,
.births = vvar$births,
.population = vvar$population
vitals = vvar
)
}

Expand Down Expand Up @@ -182,11 +142,7 @@ dplyr_reconstruct.grouped_vital <- function(data, template) {
build_vital_fable(NextMethod(),
response = attr_data$response,
distribution = attr_data$dist,
.age = vvar$age,
.sex = vvar$sex,
.deaths = vvar$deaths,
.births = vvar$births,
.population = vvar$population
vitals = vvar
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/fable.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Internal function to make a vital fable object

build_vital_fable <- function(x, response, distribution,
vitals = NULL, reorder = FALSE, ...) {
vitals = NULL, reorder = FALSE) {
final <- build_fable(x, response = response, distribution = distribution) |>
suppressWarnings()
attr(final, "vital") <- vitals[vitals %in% colnames(x)]
Expand Down

0 comments on commit 00956d3

Please sign in to comment.