formr_aggregate: Aggregate data based on item table

Description Usage Arguments Examples

View source: R/connect_to_formr.R

Description

If you've retrieved an item table using formr_items() you can use this function to aggregate your multiple choice items into mean scores. If you do not have a item table (e.g. your data was not collected using formr, you don't want another HTTP request in a time-sensitive process). Example: If your data contains Extraversion_1, Extraversion_2R and Extraversion_3, there will be two new variables in the result: Extraversion_2 (reversed to align with _1 and _2) and Extraversion, the mean score of the three.

Usage

1
2
3
4
formr_aggregate(survey_name, item_list = formr_items(survey_name, host =
  host), results = formr_raw_results(survey_name, host = host),
  host = "https://formr.org", compute_alphas = FALSE, fallback_max = 5,
  plot_likert = FALSE, ...)

Arguments

survey_name

case-sensitive name of a survey your account owns

item_list

an item_list, will be auto-retrieved based on survey_name if omitted

results

survey results, will be auto-retrieved based on survey_name if omitted

host

defaults to https://formr.org

compute_alphas

defaults to TRUE, whether to compute psych::alpha()

fallback_max

defaults to 5 - if the item_list is set to null, we will use this to reverse

plot_likert

defaults to TRUE - whether to make likert::likert() plots. Only possible if item_list is specified.

...

passed to psych::alpha()

Examples

1
2
3
4
5
6
7
results = jsonlite::fromJSON(txt = 
	system.file('extdata/gods_example_results.json', package = 'formr', mustWork = TRUE))
items = formr_items(path = 
	system.file('extdata/gods_example_items.json', package = 'formr', mustWork = TRUE))
agg = formr_aggregate(item_list = items, results = results, 
	compute_alphas = TRUE, plot_likert = TRUE)
agg[, c('religiousness', 'prefer')]

grebbel/formr_test documentation built on May 17, 2019, 8:34 a.m.