Skip to contents

Counts codings per code (rows, in code-tree order) and per value of a document variable (columns), e.g. by = "Rolle". Codes count their subcodes as well (column with_subcodes). Documents without the variable are collected in the column (ohne).

Usage

qda_case_matrix(by = NULL, percent = FALSE, unit = c("document", "case"))

Arguments

by

Name of a document variable (see qda_source_set_var()) or, with unit = "case", of a case variable (see qda_case_set_var()). With unit = "case" it may be NULL: one column per case.

percent

Logical; column percentages (share of all codings of the group) instead of counts.

unit

"document" (default) or "case".

Value

A tibble: code, path, depth, then one column per value (or case). Attribute "n_units": number of documents (or cases) per column.

Details

With unit = "case" the columns are cases instead of documents (see qda_case_add()): one column per case, or – with by – one column per value of a case variable. A coding counts for a case when it lies in one of the case's documents or passages; a coding that belongs to two cases of the same group counts once.

Examples

qda_open(file.path(tempfile(), "example.jellyqda"))
qda_import(system.file("extdata", c("interview_01.txt", "interview_02.md"), package = "jellyqda"))
#> # A tibble: 2 × 5
#>      id name             format chars status
#>   <int> <chr>            <chr>  <int> <chr> 
#> 1     1 interview_01.txt txt      856 ok    
#> 2     2 interview_02.md  md       531 ok    
qda_source_set_var(1, "role", "project lead")
qda_source_set_var(2, "role", "developer")
qda_code_add("Motivation")
qda_code(1, "Motivation", segment = 2)
qda_code(2, "Motivation", segment = 1)
qda_case_matrix("role")
#> # A tibble: 1 × 5
#>   code       path       depth developer `project lead`
#>   <chr>      <chr>      <int>     <int>          <int>
#> 1 Motivation Motivation     1         1              1
qda_case_matrix("role", percent = TRUE)
#> # A tibble: 1 × 5
#>   code       path       depth developer `project lead`
#>   <chr>      <chr>      <int>     <dbl>          <dbl>
#> 1 Motivation Motivation     1       100            100
qda_case_add("Person A", sources = 1:2)              # one person, two interviews
qda_case_matrix(unit = "case")
#> # A tibble: 1 × 4
#>   code       path       depth `Person A`
#>   <chr>      <chr>      <int>      <int>
#> 1 Motivation Motivation     1          2
qda_close()