multiple_choice_question_bar: Generates a bar plot displaying the percentage of surveyees...

Description Usage Arguments Value Examples

View source: R/multiple_choice_question_bar.R

Description

This function generally differentiates between parsing data directly from ODK using the svc option or passing data locally (df or csv). If one provides an svc, the function automatically finds all questions that received multiple choices as answers. Please note, that questions which allow multiple choices but only have received single choices are not identified as such and thus will not be displayed. This is because the extended from schema which is provided by the ODK Central API and accessed using ruODK's form_schema_ext does not provide this info. After identifying the questions, the functions also maps the question and choices labels according to their names so that the final plot contains a meaningful title and legend. By default, the function assumes that there is no language differentiation implemented in the form. If so, the argument lang has to be specified accordingly (see parameter description). If svc is set to FALSE and the data is passed locally, the argument qvec has to be specified with the column names of single-choice questions one wants to examine. Please note that for this case the column name will be displayed as the title while the row values will be displayed as the choice labels.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
multiple_choice_question_bar(
  svc = FALSE,
  df = NULL,
  csv = NULL,
  qvec = NULL,
  lang = NULL,
  df_schema_ext = NULL,
  delimiter = " ",
  choice_col = NULL,
  label_col = NULL
)

Arguments

svc

Logical that indicates whether the data shall be parsed using ruODK's odata_submission_get. Optional, defaults to FALSE.

df

Data frame containing the ODK data that is to be used. Optional, defaults to NULL.

csv

Character that specifies the path to the csv file that is to be read. Optional, defaults to NULL.

qvec

Character vector containing the column names of the single-choice questions that is to be examined, defaults to NULL. Only to be used when loading data through df or csv and when df_schema_ext is not used.

lang

Character containing the name of the language that is to be examined, defaults to NULL.

df_schema_ext

Data frame that defines the schema of the from. Can be passed to the function to avoid downloading it multiple times. Optional, defaults to NULL.

delimiter

Character specifying the symbol that is used to separate multiple choices in the data. Optional, defaults to ' '.

choice_col

String specifying the choices column that is to be changed, defaults to NULL.

label_col

String specifying the labels column that is to be changed, defaults to NULL.

Value

List

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
# 1. with SVC
# ruODK needs to be set up for this function to work
repvisforODK::setup_ruODK(svc = 'example/svc.svc', un = 'exampleusername', pw = 'examplepassword', tz = 'Europe/Berlin', verbose = TRUE)

submissions_timeseries_lineplot(svc = TRUE, lang = 'english', delimiter = ' ', choice_col = 'choices_english_(en)', label_col = 'label_english_(en)')

# 2. with data frame and external form schema
df_schema = ruODK::form_schema_ext()

submissions_timeseries_lineplot(df = df_odk_data, lang = 'english', df_schema_ext = df_schema, delimiter = ' ', choice_col = 'choices_english_(en)', label_col = 'label_english_(en)')

# 3. with csv and qvec
submissions_timeseries_lineplot(csv = 'example/file/odk_data.csv', lang = 'english', qvec = c('question1', 'question4'), delimiter = ' ', choice_col = 'choices_english_(en)', label_col = 'label_english_(en)')

## End(Not run)

lucidviews/repvisForODK documentation built on Feb. 13, 2022, 9:50 p.m.