create_unit: Create a single unit

View source: R/create_units.r

create_unitR Documentation

Create a single unit

Description

Works like create_units, but for a single unit. The values can then directly be provided in the set_ functions. The advantage of creating a single unit is that it provides more flexibility. This is especially useful for adding survey questions and units for testing or training coders.

Usage

create_unit(id, ..., type = "code", codebook = NULL)

Arguments

id

A unique id

...

Additional arguments passed to create_units

type

The unit type. Can be 'code', 'test', 'train' or 'survey'

codebook

Optionally, provide a unit-level codebook.

Value

A codingjobUnits object.

Examples

unit1 <- create_unit(
  "id",
  set_text("text", "This is the unit text")
)

## this is also a good way to create custom training units
codebook <- create_codebook(
  question("variable", question = "Is this a text?", codes = c("yes", "no"))
)

unit2 <- create_unit("id",
  type = "train",
  set_text("text", "This is the unit text"),
  set_train("variable", "yes", message = "WRONG!!\n\ntry again"),
  codebook = codebook
)

## single units are returned as a codingjobUnits list of length 1. This means
## that you can combine different units (and the results of create_units)
units <- c(unit1, unit2)

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