count_codes {manifestoR}R Documentation

Count the codings from a ManifestoDocument

Description

Count the codings from a ManifestoDocument

Usage

count_codes(
  doc,
  code_layers = c("cmp_code"),
  with_eu_codes = "auto",
  prefix = "per",
  relative = TRUE,
  include_codes = if ("cmp_code" %in% code_layers) {
     v4_categories()
 } else {
   
     c()
 },
  aggregate_v5_subcategories = TRUE,
  drop_codes = if ("cmp_code" %in% code_layers) {
     c("H")
 } else {
     c()
 }
)

Arguments

doc

ManifestoDocument, ManifestoCorpus or vector of codes

code_layers

vector of names of code layers to use, defaults to cmp_code; Caution: The layer eu_code is handled separately in the parameter with_eu_codes due to its different logic

with_eu_codes

Whether to include special EU code layer; by default ("auto") taken from the document's metadata

prefix

prefix for naming the count/percentage columns in the resulting data.frame

relative

If true, percentages are returned, absolute counts else; the percentages are calculated after the exclusion of the categories provided in 'drop_codes'

include_codes

Vector of categories that should be included even if they are not present in the data; the value of the created variables then defaults to 0.0 (or NA if no codes are present at all); in contrast to 'drop_codes' this only adds variables for possibly missing categories but does not remove any; Defaults to 'v4_categories()' if 'code_layers' parameter contains 'cmp_code'

aggregate_v5_subcategories

if TRUE, for handbook version 5 subcategories, the aggregate category's count/percentage is computed as well

drop_codes

Vector of categories that should be excluded even if they are present in the data; Defaults to 'c("H")' if 'code_layers' parameter contains 'cmp_code'

Value

A data.frame with onw row and the counts/percentages as columns


[Package manifestoR version 1.6.0 Index]