surveyPivot: surveyPivot

View source: R/surveyPivot.R

surveyPivotR Documentation

surveyPivot

Description

Survey Pivot Function

Usage

surveyPivot(
  data,
  group_column = 1,
  response_column = 2,
  sep = ",",
  NAtoZero = TRUE,
  totals = TRUE,
  percent = TRUE
)

Arguments

data

Tidy dataframe (ideally of two columns) containing group variable (e.g., ethnicity) and response variable where each row is a unique respondent.

group_column

Column of the dataframe where the group variable resides. Defaults to 1.

response_column

Column of the dataframe where the response variable resides. Defaults to 2.

sep

Do you wish to save the plot output to the session directory? Default is FALSE

NAtoZero

Do you want NA values in the pivot table to be replaced with 0? Defaults to TRUE

totals

Do you want a column containing row sums across all groups? Defaults to TRUE.

percent

Do you want to view the results as group response rates to each selection? Defaults TRUE

Details

Creates pivot table from survey data containing irregular multiple responses. Input is clean dataframe containing a group variable (e.g., race/ethnicity) and a response variable (selected responses to a survey question).

Examples

# Basic example with all defaults unchanged
## Not run: 
survey_data <- data.frame(ethnicity = c('black','black','white','white','white'),
experience = c('I did','did not','did not','I did','did not'))
surveyPivot(survey_data)

# Adjusting defaults
surveyPivot(survey_data, group_column = 2, response_column = 1,
NAtoZero = FALSE, totals = FALSE, percent = FALSE)

## End(Not run)

AMGold99/piperr documentation built on March 29, 2022, 9:46 a.m.