Learn R Programming

dateutils (version 0.1.5)

total_response: Number of of responses at a given frequency

Description

Return the total number of responses to categorical answers at a specified frequency

Usage

total_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 number of responses at the frequency

Examples

Run this code
# NOT RUN {
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 <- total_response(dt, col_name = "response")
# }

Run the code above in your browser using DataLab