Learn R Programming

dataMojo (version 1.0.0)

pivot_percent_at_multi: Create an aggragated data table with all proportion of multiple selected column

Description

Create an aggragated data table with all proportion of multiple selected column

Usage

pivot_percent_at_multi(dt, question_col, aggregated_by_cols)

Value

an aggragated data table

Arguments

dt

data table

question_col

columns selected as questions

aggregated_by_cols

grouped by columns

Examples

Run this code
test_dt <- data.table::data.table(
  Question1 = c(rep("Good", 3), rep("OK", 3), rep("Bad", 3)),
  Question2 = c(rep("Good", 2), rep("OK", 2), rep("Bad", 5)),
  Gender = c(rep("F", 4), rep("M", 5))
)
dataMojo::pivot_percent_at_multi(test_dt,
  question_col = c("Question1","Question2") , aggregated_by_cols = "Gender")

Run the code above in your browser using DataLab