Package 'qcoder'

Title: Lightweight Qualitative Coding
Description: A free, lightweight, open source option for analyzing text-based qualitative data. Enables analysis of interview transcripts, observation notes, memos, and other sources. Supports the work of social scientists, historians, humanists, and other researchers who use qualitative methods. Addresses the unique challenges faced in analyzing qualitative data analysis. Provides opportunities for researchers who otherwise might not develop software to build software development skills.
Authors: Beth Duckles [aut], Dan Sholler [aut], Elin Waring [cre], Jenny Draper [aut], Ted Laderas [aut], Fred VanWindekens [ctb], Yuri Dias [ctb], Sheriff Colley [ctb], Jamal Jones [ctb], Michael Lieberman [ctb], Tenzing Sherpa [ctb], Stephanie Guillou [ctb]
Maintainer: Elin Waring <[email protected]>
License: GPL-3 + file LICENSE
Version: 0.1.0
Built: 2024-08-29 22:58:16 UTC
Source: https://github.com/ropenscilabs/qcoder

Help Index


Add code Append a new unit record to the existing data frame

Description

Add code Append a new unit record to the existing data frame

Usage

add_code(codes_df, new_code, new_code_desc, codes_df_path)

Arguments

codes_df

Existing codes data frame

new_code

text name of a new code (single name only)

new_code_desc

text description of the code

codes_df_path

full path to the codes data frame

Examples

unlink("./_my_qcoder_project", recursive=TRUE)

Adds codes surrounding the selected text

Description

Adds codes surrounding the selected text

Usage

add_codes_to_selection(selection, codes)

Arguments

selection

The selection of text to be coded

codes

The code or codes to be added to the document


Update codes data frame Add discovered codes to the codes data frame

Description

Update codes data frame Add discovered codes to the codes data frame

Usage

add_discovered_code(
  codes_list = "",
  code_data_frame = NULL,
  codes_df_path = ""
)

Arguments

codes_list

A list of codes (usually from a coded document)

code_data_frame

Existing data frame of QCODE codes

codes_df_path

The path where the updated code data frame should be saved


Add new documents Adds new document or documents to an existing documents data frame.

Description

Add new documents Adds new document or documents to an existing documents data frame.

Usage

add_new_documents(files, docs_df_path = "", file_path = "")

Arguments

files

Vector of new files to be added

docs_df_path

Path to existing data frame of text documents

file_path

Full path to the data set of documents including trailing slash

Examples

create_qcoder_project(project_name = "my_qcoder_project", sample = TRUE)

unlink("./my_qcoder_project", recursive=TRUE)

Add unit Append a new unit record to the existing data frame

Description

Add unit Append a new unit record to the existing data frame

Usage

add_unit(units_df, new_unit, units_df_path)

Arguments

units_df

Existing units data frame

new_unit

text name of a new unit (single name only)

units_df_path

full path to the units data frame

Examples

unlink("./_my_qcoder_project", recursive=TRUE)

Build the paths for file creation

Description

Builds the paths to the data to be imported and to the data frame where the imported data is to be stored. The project name is required, all other parameters may be set. These each represent a segment of the path to a file. If a project path is not set or set to "" it will be set to the current working directory via getwd(). The Shiny qcode application assumes that the data frame folder will be "data_frames" and that any new documents to be imported will be in a folder called "documents".

Usage

build_paths(
  project_name,
  data_path = "",
  data_frame_name = "",
  df_path = "data_frames",
  project_path = ""
)

Arguments

project_name

Name of the project

data_path

Path segment to the data. The format for this may depend on the function using the paths.

data_frame_name

Name of the data frame that will contain the data

df_path

path segment(s) to the created data frame file from the project path

project_path

Path to the project (not including project_name). This will be set to getwd() if a value of "" is passed in.

Value

A named list of paths. "data_frame_path" is the path to the data frame and "data" is the path to the data.


Create an empty codes data set

Description

Used to create a codes data frame with no data but that can have data added. File is placed in the data_frames folder.

Usage

create_empty_code_file(path)

Arguments

path

Full path to data frame to be created.

Examples

create_qcoder_project(project_name = "_my_qcoder_project")
path <- file.path(getwd(),
  "_my_qcoder_project/data_frames/qcoder_codes__my_qcoder_project")
create_empty_docs_file(path)
unlink("./_my_qcoder_project", recursive=TRUE)

Create an empty documents data set

Description

Used to create a codes data frame with no data but that can have data added. File is placed in the data_frames folder.

Usage

create_empty_docs_file(path)

Arguments

path

Full path to data frame to be created.

Examples

create_qcoder_project(project_name = "_my_qcoder_project")
path <- file.path(getwd(),
  "_my_qcoder_project/data_frames/qcoder_docs__my_qcoder_project")
create_empty_docs_file(path)
unlink("./_my_qcoder_project", recursive=TRUE)

Define an empty many to many unit to document map

Description

Define an empty many to many unit to document map

Usage

create_empty_unit_doc_file(path)

Arguments

path

Full path to data frame to be created.

Examples

create_qcoder_project(project_name = "_my_qcoder_project")
path <- file.path(getwd(),
  "_my_qcoder_project/data_frames/qcoder_units_document_map__my_qcoder_project")
create_empty_docs_file(path)
unlink("./_my_qcoder_project", recursive=TRUE)

Define an empty units data frame

Description

Define an empty units data frame

Usage

create_empty_units_file(path)

Arguments

path

Full path to data frame to be created.

Examples

create_qcoder_project(project_name = "_my_qcoder_project")
path <- file.path(getwd(),
  "_my_qcoder_project/data_frames/qcoder_units__my_qcoder_project")
create_empty_docs_file(path)
unlink("./_my_qcoder_project", recursive=TRUE)

Create a standard set of folders for a QCoder project

Description

Create a standard set of folders for a QCoder project

Usage

create_qcoder_project(project_name, sample = FALSE)

Arguments

project_name

A string project name to be located in the current working directory or a path to a project folder.

sample

Logical that indicates that the sample data should be copied to the project.

Examples

create_qcoder_project(project_name = "my_qcoder_project")
unlink("./my_qcoder_project", recursive=TRUE)

Update document Updates the text field of the documents data frame, typically after pressing Save button in the Shiny App. May also be used in the console.

Description

Update document Updates the text field of the documents data frame, typically after pressing Save button in the Shiny App. May also be used in the console.

Usage

do_update_document(updated, docs_df_path, this_doc_path)

Arguments

updated

The updated text as a character string

docs_df_path

Location of the documents rds file.

this_doc_path

Name of record to be updated, as recorded in "doc_path" field of data frame.

Examples

unlink("./_my_qcoder_project", recursive=TRUE)

Check for coding errors

Description

Checks the current document for coding errors.

Usage

error_check(document)

Arguments

document

A string to be scanned for errors.

Details

This function takes a string (such as the contents of a document), and conducts some basic linting. It returns a warning if there aren't a matching number of (QCODE) tags, or if text has been marked to be captured but the capture is missing a tag (missing {#my_tag}).

Value

A warning message as a character string.

Examples

error_check("An (QCODE)unmatched set of (QCODE) gives (/QCODE){#tag} a warning.")
error_check("A (QCODE) qcode with a missing tag gives a warning.")

Extract codes from text Take coded text and extract the codes, assuming they are correctly formatted.

Description

Extract codes from text Take coded text and extract the codes, assuming they are correctly formatted.

Usage

get_codes(doc_text)

Arguments

doc_text

The text data for a single document

Examples

unlink("./my_qcoder_project", recursive=TRUE)

Read data into a project Convenience method to read raw data from standard locations and using standard names in a project folder structure.

Description

Read data into a project Convenience method to read raw data from standard locations and using standard names in a project folder structure.

Usage

import_project_data(project_name)

Arguments

project_name

The project name. This should represent the folder holding the project.

Examples

create_qcoder_project(project_name = "_my_qcoder_project", sample = TRUE)
import_project_data("_my_qcoder_project")
unlink("./_my_qcoder_project", recursive=TRUE)

Parse one document

Description

Parse one document

Usage

parse_one_document(doc, df, qcoder_documents, dots = NULL)

Arguments

doc

A single document from qcoder_data

df

The data frame that will contain the parsed data

qcoder_documents

The full documents data frame

dots

Other parameters that may be passed in.

Examples

unlink("./my_qcoder_project", recursive=TRUE)

Parse coded text

Description

Take a data frame of coded text documents and return a data frame of the codes captured within.

Usage

parse_qcodes(x, ...)

Arguments

x

A data frame containing the text to be coded; requires columns "doc_id" and "document_text"

...

Other parameters optionally passed in

Details

This function takes a text document containing coded text of the form:

"stuff to ignore (QCODE) coded text we care about (/QCODE){#my_code}
more stuff to ignore"

and turns it into a data frame with one row per coded item, of the form: docid,qcode,text

parse_qcodes assumes that it is being passed a data frame, the parse_one_document function is called to do the heavy lifting extracting the coded text from the document_text column.

Newline characters are replaced with an HTML <br> in the captured text.

If no valid qcodes are found, parse_qcodes returns an empty data frame (no rows).

Value

If the data frame contains coded text in the document_text column, output will be a data frame with three columns: "doc", "qcode", and "text".

    The \code{doc} is the \code{doc_id} from the input data frame.

    \code{qcode} is the code that the captured text was marked up with.

    \code{text} is the text that was captured.

Examples

parse_qcodes(my_documents)

# Data frames can be piped into this function
my_documents %>%
  parse_qcodes()

Parse a single item within a document

Description

Parse a single item within a document

Usage

parse_splititem(splititem, df, doc_id, dots)

Arguments

splititem

String usually generated by parse_one_document()

df

Data frame for storing parsed data

doc_id

The doc_id for the document this string is part of.

dots

List of additional options passed in.


This launches the coder Shiny app

Description

This launches the coder Shiny app

Usage

qcode(use_wd = TRUE)

Arguments

use_wd

Whether or not the current working directory when launching qcoder should be used as the base from which the project file is selected.

Examples

if (interactive()) {
 qcode()
}

This launches the coder custom Shiny app

Description

This launches the coder custom Shiny app

Usage

qcode_custom()

Examples

if (interactive()) {
  qcode_custom()
}

Create a file of codes from csv file Use this if you have a spreadsheet of codes already created.

Description

Create a file of codes from csv file Use this if you have a spreadsheet of codes already created.

Usage

read_code_data(
  project_name,
  data_path = "codes/codes.csv",
  df_path = "data_frames",
  data_frame_name = "qcoder_codes",
  project_path = ""
)

Arguments

project_name

Name of the project, which matches folder name

data_path

Path to a file containing code data in csv.

df_path

Full path to the codes data frame.

data_frame_name

The name of the RDS file that the data frame will be stored in.

project_path

Full path to the project folder

Examples

create_qcoder_project(project_name = "_my_qcoder_project", sample = TRUE)
read_code_data(project_name = "_my_qcoder_project")
unlink("./_my_qcoder_project", recursive=TRUE)

This launches the data-reader Shiny app

Description

This launches the data-reader Shiny app

Usage

read_data()

Examples

## Not run: 
 read_data()

## End(Not run)

Create a data frame of documents

Description

Create a data frame of documents

Usage

read_documents_data(
  project_name,
  data_path = "documents/",
  df_path = "data_frames",
  data_frame_name = "qcoder_documents",
  project_path = ""
)

Arguments

project_name

Name of the Qcoder project

data_path

path to a folder contain text files to be analyzed.

df_path

Full path to the docs data frame.

data_frame_name

The name of the RDS file that the data frame will be stored in.

project_path

Full path to the project folder.

Examples

## Not run: 
read_documents_data("_my_qcoder_project")

## End(Not run)

Create a data frame of units from csv file Use this is you have a spreadsheet of units already created.

Description

Create a data frame of units from csv file Use this is you have a spreadsheet of units already created.

Usage

read_unit_data(
  data_path = "units/units.csv",
  data_frame_name = "qcoder_units",
  project_name,
  project_path = "",
  df_path = "data_frames"
)

Arguments

data_path

path to a file containing unit data in csv.

data_frame_name

The name of the RDS file that the data frame will be stored in.

project_name

Name of project if available

project_path

Full path to the project folder.

df_path

Full path to the units data frame.

Examples

create_qcoder_project(project_name = "_my_qcoder_project", sample = TRUE)
read_unit_data(project_name = "_my_qcoder_project")
unlink("./_my_qcoder_project", recursive=TRUE)

Create a data frame of unit to document links from csv file Use this is you have a spreadsheet already created.

Description

Create a data frame of unit to document links from csv file Use this is you have a spreadsheet already created.

Usage

read_unit_document_map_data(
  project_name,
  data_path = "units/unit_document_map.csv",
  data_frame_name = "qcoder_unit_document_map",
  project_path = "",
  df_path = "data_frames"
)

Arguments

project_name

Name of project

data_path

path to a file containing unit document map data in csv.

data_frame_name

The name of the RDS file that the data frame will be stored in.

project_path

Full path to the project folder

df_path

Full path to the documents data frame.

Examples

create_qcoder_project(project_name = "_my_qcoder_project", sample = TRUE)
project_name = "_my_qcoder_project"
read_unit_document_map_data( project_name = "_my_qcoder_project")
unlink("./_my_qcoder_project", recursive=TRUE)

Format text as HTML Minimal conversion of a text to html

Description

Format text as HTML Minimal conversion of a text to html

Usage

txt2html(text)

Arguments

text

text to be converted

Examples

txt2html("The quick brown (QCODE)fox(/QCODE){#animal} jumped over ")

Check for a valid qcoder project

Description

Check for a valid qcoder project

Usage

validate_project(path_to_test)

Arguments

path_to_test

Path to possible project folder

Value

NULL for valid project, Error otherwise.

Examples

create_qcoder_project(project_name = "_my_qcoder_project")
validate_project("_my_qcoder_project")
unlink("./_my_qcoder_project", recursive=TRUE)

Check for required imported data frames.

Description

Check for required imported data frames.

Usage

validate_project_files(path_to_test)

Arguments

path_to_test

Path to possible project folder

Value

NULL for valid project, Error otherwise.

Examples

create_qcoder_project(project_name = "_my_qcoder_project", sample = TRUE)
import_project_data("_my_qcoder_project")
validate_project_files("_my_qcoder_project")
unlink("./_my_qcoder_project", recursive=TRUE)