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-11-27 03:40:16 UTC |
Source: | https://github.com/ropenscilabs/qcoder |
Light weight coding
Add code Append a new unit record to the existing data frame
add_code(codes_df, new_code, new_code_desc, codes_df_path)
add_code(codes_df, new_code, new_code_desc, codes_df_path)
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 |
unlink("./_my_qcoder_project", recursive=TRUE)
unlink("./_my_qcoder_project", recursive=TRUE)
Adds codes surrounding the selected text
add_codes_to_selection(selection, codes)
add_codes_to_selection(selection, codes)
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
add_discovered_code( codes_list = "", code_data_frame = NULL, codes_df_path = "" )
add_discovered_code( codes_list = "", code_data_frame = NULL, codes_df_path = "" )
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.
add_new_documents(files, docs_df_path = "", file_path = "")
add_new_documents(files, docs_df_path = "", file_path = "")
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 |
create_qcoder_project(project_name = "my_qcoder_project", sample = TRUE) unlink("./my_qcoder_project", recursive=TRUE)
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
add_unit(units_df, new_unit, units_df_path)
add_unit(units_df, new_unit, units_df_path)
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 |
unlink("./_my_qcoder_project", recursive=TRUE)
unlink("./_my_qcoder_project", recursive=TRUE)
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".
build_paths( project_name, data_path = "", data_frame_name = "", df_path = "data_frames", project_path = "" )
build_paths( project_name, data_path = "", data_frame_name = "", df_path = "data_frames", project_path = "" )
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. |
A named list of paths. "data_frame_path" is the path to the data frame and "data" is the path to the data.
Used to create a codes data frame with no data but that can have data added. File is placed in the data_frames folder.
create_empty_code_file(path)
create_empty_code_file(path)
path |
Full path to data frame to be created. |
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_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)
Used to create a codes data frame with no data but that can have data added. File is placed in the data_frames folder.
create_empty_docs_file(path)
create_empty_docs_file(path)
path |
Full path to data frame to be created. |
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)
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
create_empty_unit_doc_file(path)
create_empty_unit_doc_file(path)
path |
Full path to data frame to be created. |
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)
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
create_empty_units_file(path)
create_empty_units_file(path)
path |
Full path to data frame to be created. |
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_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
create_qcoder_project(project_name, sample = FALSE)
create_qcoder_project(project_name, sample = FALSE)
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. |
create_qcoder_project(project_name = "my_qcoder_project") unlink("./my_qcoder_project", recursive=TRUE)
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.
do_update_document(updated, docs_df_path, this_doc_path)
do_update_document(updated, docs_df_path, this_doc_path)
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. |
unlink("./_my_qcoder_project", recursive=TRUE)
unlink("./_my_qcoder_project", recursive=TRUE)
Checks the current document for coding errors.
error_check(document)
error_check(document)
document |
A string to be scanned for errors. |
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}
).
A warning
message as a character string.
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.")
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.
get_codes(doc_text)
get_codes(doc_text)
doc_text |
The text data for a single document |
unlink("./my_qcoder_project", recursive=TRUE)
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.
import_project_data(project_name)
import_project_data(project_name)
project_name |
The project name. This should represent the folder holding the project. |
create_qcoder_project(project_name = "_my_qcoder_project", sample = TRUE) import_project_data("_my_qcoder_project") unlink("./_my_qcoder_project", recursive=TRUE)
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
parse_one_document(doc, df, qcoder_documents, dots = NULL)
parse_one_document(doc, df, qcoder_documents, dots = NULL)
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. |
unlink("./my_qcoder_project", recursive=TRUE)
unlink("./my_qcoder_project", recursive=TRUE)
Take a data frame of coded text documents and return a data frame of the codes captured within.
parse_qcodes(x, ...)
parse_qcodes(x, ...)
x |
A data frame containing the text to be coded; requires columns "doc_id" and "document_text" |
... |
Other parameters optionally passed in |
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).
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.
parse_qcodes(my_documents) # Data frames can be piped into this function my_documents %>% parse_qcodes()
parse_qcodes(my_documents) # Data frames can be piped into this function my_documents %>% parse_qcodes()
Parse a single item within a document
parse_splititem(splititem, df, doc_id, dots)
parse_splititem(splititem, df, doc_id, dots)
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
qcode(use_wd = TRUE)
qcode(use_wd = TRUE)
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. |
if (interactive()) { qcode() }
if (interactive()) { qcode() }
This launches the coder custom Shiny app
qcode_custom()
qcode_custom()
if (interactive()) { qcode_custom() }
if (interactive()) { qcode_custom() }
Create a file of codes from csv file Use this if you have a spreadsheet of codes already created.
read_code_data( project_name, data_path = "codes/codes.csv", df_path = "data_frames", data_frame_name = "qcoder_codes", project_path = "" )
read_code_data( project_name, data_path = "codes/codes.csv", df_path = "data_frames", data_frame_name = "qcoder_codes", project_path = "" )
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 |
create_qcoder_project(project_name = "_my_qcoder_project", sample = TRUE) read_code_data(project_name = "_my_qcoder_project") unlink("./_my_qcoder_project", recursive=TRUE)
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
read_data()
read_data()
## Not run: read_data() ## End(Not run)
## Not run: read_data() ## End(Not run)
Create a data frame of documents
read_documents_data( project_name, data_path = "documents/", df_path = "data_frames", data_frame_name = "qcoder_documents", project_path = "" )
read_documents_data( project_name, data_path = "documents/", df_path = "data_frames", data_frame_name = "qcoder_documents", project_path = "" )
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. |
## Not run: read_documents_data("_my_qcoder_project") ## End(Not run)
## 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.
read_unit_data( data_path = "units/units.csv", data_frame_name = "qcoder_units", project_name, project_path = "", df_path = "data_frames" )
read_unit_data( data_path = "units/units.csv", data_frame_name = "qcoder_units", project_name, project_path = "", df_path = "data_frames" )
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. |
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_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.
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" )
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" )
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. |
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)
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
txt2html(text)
txt2html(text)
text |
text to be converted |
txt2html("The quick brown (QCODE)fox(/QCODE){#animal} jumped over ")
txt2html("The quick brown (QCODE)fox(/QCODE){#animal} jumped over ")
Update document to unit links Saves or updates the links between observation units and documents
update_links( checked = "", docs_df_path = "", this_doc_path = "", units_docs_path = "" )
update_links( checked = "", docs_df_path = "", this_doc_path = "", units_docs_path = "" )
checked |
vector of new or updated links |
docs_df_path |
full path to document dataset |
this_doc_path |
value of doc_path for the document |
units_docs_path |
full path of the data frame of unit to docs links |
unlink("./_my_qcoder_project", recursive=TRUE)
unlink("./_my_qcoder_project", recursive=TRUE)
Check for a valid qcoder project
validate_project(path_to_test)
validate_project(path_to_test)
path_to_test |
Path to possible project folder |
NULL for valid project, Error otherwise.
create_qcoder_project(project_name = "_my_qcoder_project") validate_project("_my_qcoder_project") unlink("./_my_qcoder_project", recursive=TRUE)
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.
validate_project_files(path_to_test)
validate_project_files(path_to_test)
path_to_test |
Path to possible project folder |
NULL for valid project, Error otherwise.
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)
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)