Skip to content

Commit

Permalink
final attempt to make main stable fix #45
Browse files Browse the repository at this point in the history
  • Loading branch information
erika-redding committed Jan 18, 2024
1 parent 8e3fb13 commit 336d629
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 22 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RoxygenNote: 7.2.3
Imports:
data.table,
dplyr,
magrittr,
srvyr,
stats,
stringr
Expand Down
13 changes: 10 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(factorize_column)
export(factorize_df)
export(hts_bin_var)
Expand All @@ -20,6 +21,12 @@ export(hts_summary_num)
export(hts_to_so)
export(hts_trip_vehid)
import(data.table)
import(dplyr)
import(srvyr)
import(stats)
importFrom(data.table,melt)
importFrom(dplyr,group_by_at)
importFrom(dplyr,summarize)
importFrom(magrittr,"%>%")
importFrom(srvyr,survey_mean)
importFrom(srvyr,survey_median)
importFrom(srvyr,survey_prop)
importFrom(srvyr,survey_total)
importFrom(stats,quantile)
2 changes: 1 addition & 1 deletion R/hts_bin_var.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @export
#'
#'
#' @import stats
#' @importFrom stats quantile
#'
#' @examples
#'
Expand Down
2 changes: 1 addition & 1 deletion R/hts_find_var.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @param var searchable variable in string format
#' @param variables_dt codebook variable list in data table format
#'
#' @import data.table
#' @importFrom data.table melt
#'
#' @return variable location in string format
#' @export
Expand Down
2 changes: 2 additions & 0 deletions R/hts_melt_vars.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#' @param to_single_row Boolean if treating multiple checkbox selections as 'Two
#' or more'. Defaults to FALSE.
#'
#' @import data.table
#'
#' @return Inputted data table with checkbox variables melted into a single variable,
#' with a 'variable' column to indicate original variable names and a 'value' column
#' with the original value of the checkbox variable.
Expand Down
9 changes: 6 additions & 3 deletions R/hts_summary_cat.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
#' @param checkbox_yesval Value of checkbox_valname that indicates it was selected.
#' Default is NULL. Must be provided if summarize_var is a checkbox variable.
#'
#' @import dplyr
#' @import srvyr
#'
#' @importFrom srvyr survey_prop
#' @importFrom srvyr survey_total
#' @importFrom dplyr summarize
#' @importFrom dplyr group_by_at
#'
#' @return List of unweighted and weighted categorical summaries including counts
#' and proportions.
Expand Down Expand Up @@ -290,5 +293,5 @@ hts_summary_cat = function(prepped_dt,
}

## quiets concerns of R CMD check
utils::globalVariables(c("value_labels", "prop", "est"))
utils::globalVariables(c("value_labels", "prop", "est", "count"))

5 changes: 5 additions & 0 deletions R/hts_summary_num.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
#' when weighted = TRUE.
#' @param strataname Name of strata name to bring in. Default is NULL.
#'
#' @importFrom srvyr survey_mean
#' @importFrom srvyr survey_median
#' @importFrom dplyr summarize
#' @importFrom dplyr group_by_at
#'
#' @return List of unweighted and weighted numeric summaries including count, min,
#' max, mean, se, and median.
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/hts_trip_vehid.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ before proceding.")
}

## quiets concerns of R CMD check
utils::globalVariables(c("value_labels", "vehicle_id", "mode_1", "mode_type"))
utils::globalVariables(c("value_labels", "vehicle_id", "mode_1", "mode_type", "hh_id"))

14 changes: 14 additions & 0 deletions R/utils-pipe.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#' Pipe operator
#'
#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details.
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
#' @param lhs A value or the magrittr placeholder.
#' @param rhs A function call using the magrittr semantics.
#' @return The result of calling `rhs(lhs)`.
NULL
19 changes: 8 additions & 11 deletions man/hts_filter_data.Rd

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

20 changes: 20 additions & 0 deletions man/pipe.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test_hts_filter_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ library(data.table)
hts_data = test_data

# Call the function to filter based on hh_id
result_hh = hts_filter_data(hts_data, hh[num_people > 5, hh_id], id_type = 'hh')
result_hh = hts_filter_data(hts_data, hh[num_people > 5, hh_id], id_name = 'hh')

# Check if the result is a list
expect_is(result_hh, "list",
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test_hts_summary_num.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ context("Test suite for hts_summary_num function")
# Load necessary libraries and setup environment
library(testthat)
library(data.table)
library(srvyr)


DT = hts_prep_data(summarize_var = 'speed_mph',
Expand Down
4 changes: 3 additions & 1 deletion vignettes/getting_started.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ In order to create summaries of our data we first need to prepare our data. We c
```{r, hts_prep_data, eval=TRUE, echo=TRUE }
library(travelSurveyTools)
library(data.table)
library(srvyr)
# Load data
data("test_data")
Expand Down Expand Up @@ -264,7 +266,7 @@ DT = hts_prep_triprate(summarize_by = 'employment',
'vehicle' = vehicle))
trip_rate_by_employment_summary = hts_summary(prepped_dt = DT$num,
summarize_var = 'num_trips',
summarize_var = 'num_trips_wtd',
summarize_by = 'employment',
summarize_vartype = 'numeric',
weighted = TRUE,
Expand Down

0 comments on commit 336d629

Please sign in to comment.