Skip to content

Commit

Permalink
added warning message to remove outliers and defaulted to false in pr…
Browse files Browse the repository at this point in the history
…ep triprate #159
  • Loading branch information
erika-redding committed Jun 17, 2024
1 parent 625e8cc commit 22d3d06
Show file tree
Hide file tree
Showing 19 changed files with 140 additions and 129 deletions.
2 changes: 1 addition & 1 deletion R/hts_prep_triprate.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ hts_prep_triprate = function(summarize_by = NULL,
day_name = "day",
ids = c("hh_id", "person_id", "day_id", "trip_id", "vehicle_id"),
wts = c("hh_weight", "person_weight", "day_weight", "trip_weight", "hh_weight"),
remove_outliers = TRUE,
remove_outliers = FALSE,
threshold = 0.975,
weighted = TRUE,
hts_data = list(hts_data)) {
Expand Down
8 changes: 8 additions & 0 deletions R/hts_remove_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
#' @examples
#'
#' require(data.table)
#'
#' hts_remove_outliers(var_dt = trip, numvar = "speed_mph")
#'
hts_remove_outliers = function(var_dt, numvar = NULL,
threshold = 0.975) {

outlier_storage = list()

outlier_cutoff = quantile(var_dt[, get(numvar)], threshold, na.rm = TRUE)
Expand All @@ -26,6 +28,12 @@ hts_remove_outliers = function(var_dt, numvar = NULL,
max_outlier = max(var_dt[get(numvar) >= outlier_cutoff, get(numvar)])
)

if (outlier_table$num_removed > 0) {
warning(stringr::str_glue(
"{outlier_table$num_removed} outliers were removed based on the threshold of {threshold}."
))
}

outlier_storage[["outlier_description"]] = outlier_table

outlier_storage[["dt"]] = var_dt[get(numvar) < outlier_cutoff]
Expand Down
64 changes: 33 additions & 31 deletions docs/articles/a01_getting_started.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions docs/articles/a03_trip_rates.html

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ articles:
a01_getting_started: a01_getting_started.html
a02_geographic_summaries: a02_geographic_summaries.html
a03_trip_rates: a03_trip_rates.html
last_built: 2024-06-17T16:33Z
last_built: 2024-06-17T16:55Z
urls:
reference: https://rsginc.github.io/travelSurveyTools/reference
article: https://rsginc.github.io/travelSurveyTools/articles
Expand Down
110 changes: 51 additions & 59 deletions docs/reference/hts_prep_triprate.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/reference/hts_prep_variable.html

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

2 changes: 2 additions & 0 deletions docs/reference/hts_remove_outliers.html

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

1 change: 1 addition & 0 deletions docs/reference/hts_summary.html

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

2 changes: 2 additions & 0 deletions docs/reference/hts_summary_num.html

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

1 change: 1 addition & 0 deletions docs/reference/hts_summary_wrapper.html

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

60 changes: 30 additions & 30 deletions docs/reference/hts_trip_vehid.html

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

2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion man/hts_prep_triprate.Rd

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

1 change: 1 addition & 0 deletions man/hts_remove_outliers.Rd

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

1 change: 1 addition & 0 deletions tests/testthat/test_hts_prep_triprate.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ test_that("hts_prep_triprate should return counts and units", {
results = hts_prep_triprate(
summarize_by = "age",
variables_dt = variable_list,
remove_outliers = TRUE,
hts_data = test_data
)

Expand Down

0 comments on commit 22d3d06

Please sign in to comment.