pct_response {dateutils}R Documentation

Percent of responses at a given frequency

Description

Return the percent of responses to categorical answers at a specified frequency

Usage

pct_response(
  dt,
  col_name = NULL,
  by = c("month", "quarter", "week"),
  date_name = "ref_date"
)

Arguments

dt

data table of responses

col_name

name of column containing responses

by

frequency of response aggregation, one of '"month"', '"quarter"', '"week"'

date_name

name of column containing dates

Value

The percent of responses at the frequency

Examples

dt <- data.frame("ref_date" = seq.Date(as.Date("2000-01-01"), length.out = 100, by = "week"),
                 "response" = c(rep("yes", 20), rep("no",50),rep("yes",30)))
out <- pct_response(dt, col_name = "response")

[Package dateutils version 0.1.5 Index]