question: Create an annotation nquestion

View source: R/question.r

questionR Documentation

Create an annotation nquestion

Description

Creates a question that can be passed as an argument to create_codebook.

Usage

question(
  name,
  question = NULL,
  codes = NULL,
  type = c("buttons", "dropdown", "scale", "annotinder", "inputs", "confirm"),
  instruction = NULL,
  color = NULL,
  fields = NULL,
  per_field = NULL,
  vertical = FALSE,
  same_size = TRUE,
  items = NULL
)

Arguments

name

The name/label of the question. Recommended to keep short. Cannot contain a "."

question

A short (think 1 or 2 sentences) question.

codes

The codes that the coder can choose from. Can be a character vector, named character vector or data.frame. An unnamed character vector creates simple codes. A named character vector uses the names as colors, either as HEX or a name recognized by browsers (see https://www.w3schools.com/colors/colors_names.asp). A data.frame must have a code column, and can use certain special columns (see details). For most control, codes can be a list of 'code' objects created with code.

type

The type of question. Can be "buttons", "dropdown", "scale", "annotinder" or "inputs". "buttons" shows all answers as buttons, "dropdown" gives a dropdown menu with a search bar. "scale" is for ordered buttons, and multiple items can be specified to answer this question for each. "annotinder" lets users swipe for answers, and can only be used if the number of answers is 2 (left, right) or 3 (left, right, up). "inputs" can create one or multiple open input fields for text and numbers.

instruction

Optionally, a markdown string with instructions for this specific question. Coders can see these instructions by clicking on the questionmark symbol before the question.

color

If no colors are given to specific codes, this sets the default color. Color should be HEX or a name recognized by browsers (see https://www.w3schools.com/colors/colors_names.asp). If NULL (default) the annotator client decides the default color.

fields

Optionally, an array of field names (i.e. the column names used in set_text, set_markdown and set_image). When the question is asked, these fields will then be focused on.

per_field

If a unit has numbered fields, the question can be automatically repeated for each field. For instance, if "per_field" is "comment", and the unit has fields "comment.1", "comment.2", etc., then this question will be repeated for each comment. The easiest way to set this up is to use the "split" argument in set_text and set_markdown, which automatically split a field into numbered fields.

vertical

If "buttons" selection is used, this puts all buttons on the same row (just make sure not to have too many buttons)

same_size

If "buttons" selection is used, make all buttons the same size.

items

Can be used for "scale" and "inputs" type questions. Should be a named list where the names are the item names, and value is a list with parameters.

Details

Using a data.frame for the codes argument gives more flexibility. This data.frame should have a "code" column, and can in addition have a "color" and "parent" column The color should be a color name, either as HEX or a name recognized by browsers (see https://www.w3schools.com/colors/colors_names.asp) The parent column is only relevant if you have many codes and use selection="dropdown". The dropdown menu will then show the codes with parent names, and parent names are included in the search string. A parent can be the name of another code, and parents can have parents, thus creating trees (just make sure not to create cycles). Use case would for example be an ontology with actor -> government -> president, and issue -> economy -> taxes.

Value

A question object, to be used within the create_codebook function


ccs-amsterdam/ccsAnnotator documentation built on March 19, 2024, 2:14 a.m.