Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

70 document what the functions return in more detail #73

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions R/hts_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@
#' @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.
#'
#' @return A data.table containing
#' @return A list containing (if applicable) categorical and numeric summaries of the
#' specified variable(s), as well as sample sizes and whether or not the summarized
#' variable is a shared checkbox variable.
#' To access the categorical/numeric df use output$summary.
#' To access the weighted df use output$summary$wtd, and output$summary$unwtd for the
#' unweighted df.
#' To access the weight name use output$summary$weight_name.
#' To access sample sizes use output$n_ls.
#' To access weighted and unweighted sample sizes respectively, use output$n_ls$wtd
#' and output$n_ls$unwtd.
#' @export
#'
#' @examples
Expand All @@ -38,11 +47,11 @@
#' 'day' = day,
#' 'trip' = trip,
#' 'vehicle' = vehicle))$cat
#' hts_summary(prepped_dt = DT,
#' summarize_var = 'age',
#' summarize_by = 'employment',
#' summarize_vartype = 'categorical',
#' wtname = 'person_weight')
#' output = hts_summary(prepped_dt = DT,
#' summarize_var = 'age',
#' summarize_by = 'employment',
#' summarize_vartype = 'categorical',
#' wtname = 'person_weight')
#'
#' DT = hts_prep_data(summarize_var = 'speed_mph',
#' summarize_by = 'age',
Expand All @@ -52,11 +61,13 @@
#' 'day' = day,
#' 'trip' = trip,
#' 'vehicle' = vehicle))$num
#' hts_summary(prepped_dt = DT,
#' summarize_var = 'speed_mph',
#' summarize_by = 'age',
#' summarize_vartype = 'numeric',
#' wtname = 'trip_weight')
#' output = hts_summary(prepped_dt = DT,
#' summarize_var = 'speed_mph',
#' summarize_by = 'age',
#' summarize_vartype = 'numeric',
#' wtname = 'trip_weight')
#'


hts_summary = function(
prepped_dt,
Expand Down
6 changes: 6 additions & 0 deletions R/hts_summary_num.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ hts_summary_num = function(prepped_dt,

}

if (weighted){

num_summary_ls$weight_name = wtname

}

return(num_summary_ls)

}
Expand Down
32 changes: 21 additions & 11 deletions man/hts_summary.Rd

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

Loading