| Title: | Techniques for Automated Classifiers |
|---|---|
| Description: | A set of techniques that can be used to develop, validate, and implement automated classifiers. A powerful tool for transforming raw data into meaningful information, 'ncodeR' (Shaffer, D. W. (2017) Quantitative Ethnography. ISBN: 0578191687) is designed specifically for working with big data: large document collections, logfiles, and other text data. |
| Authors: | Cody L Marquart [aut, cre]
|
| Maintainer: | Cody L Marquart <[email protected]> |
| License: | GPL-3 | file LICENSE |
| Version: | 0.2.1.1 |
| Built: | 2026-09-15 09:17:08 UTC |
| Source: | https://gitlab.com/epistemic-analytics/qe-packages/ncoder |
Code to data.frame
## S3 method for class 'Code' as.data.frame(x, row.names = NULL, optional = FALSE, ...)## S3 method for class 'Code' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
x |
Code object to convert |
row.names |
NULL or a character vector giving the row names for the data frame. Missing values are not allowed. |
optional |
logical. If TRUE, setting row names and converting column names |
... |
additional arguments to be passed to or from methods |
data.frame
data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) as.data.frame(newcode)data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) as.data.frame(newcode)
CodeSet to data.frame
## S3 method for class 'CodeSet' as.data.frame(x, row.names = NULL, optional = FALSE, ...)## S3 method for class 'CodeSet' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
x |
CodeSet to convert |
row.names |
NULL or a character vector giving the row names for the data frame. Missing values are not allowed. |
optional |
logical. If TRUE, setting row names and converting column names |
... |
additional arguments to be passed to or from methods |
data.frame
data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) code.set = code.set("Demo RS CodeSet", "CodeSet made for the demo", excerpts = rs$text, codes = c(newcode)) as.data.frame(code.set)data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) code.set = code.set("Demo RS CodeSet", "CodeSet made for the demo", excerpts = rs$text, codes = c(newcode)) as.data.frame(code.set)
Autocodes all codes provided, either directly with code or as part of a provided codeset
autocode( x = NULL, expressions = NULL, excerpts = NULL, simplify = T, mode = "all" )autocode( x = NULL, expressions = NULL, excerpts = NULL, simplify = T, mode = "all" )
x |
Object to autocode. Either a Code or CodeSet |
expressions |
Expressions to use for coding (optional) |
excerpts |
Excerpts to code |
simplify |
If TRUE, returns a data.frame, else returns a Code or CodeSet object |
mode |
Either all, training, or test representing the set of excerpts that should be recoded in the computerSet |
data.frame of is simplify = T (default), otherwise the Code or CodeSet object with updated computerSets
ncodeR Code object
ncodeR Code object
Code object Create Code
callTBD
nameTBD
definitionTBD
codeSetTBD
testSetTBD
trainingSetTBD
computerSetTBD
ignoredSetTBD
examplesTBD
excerptsTBD
holdoutExcerptsTBD
touchableExcerptsTBD
touchedIndicesTBD
additionalExcerptsTBD
secondRaterSetTBD
statisticsTBD
baserateTBD
baserateInflationTBD
new()
Code$new( name, definition, testSet = NULL, trainingSet = NULL, computerSet = NULL, secondRaterSet = NULL, ignoredSet = c(), examples = NULL, excerpts = NULL, holdoutSize = 0.9, ... )
nameTBD
definitionTBD
testSetTBD
trainingSetTBD
computerSetTBD
secondRaterSetTBD
ignoredSetTBD
examplesTBD
excerptsTBD
holdoutSizeTBD
...TBD
Code object Function to override
process()
Code$process()
Default, error, unless overridden Kappa on Code
kappa()
Code$kappa(which = c("training", "test"))whichTBD
double Differences in sets
differences()
Code$differences(data = NULL, col1 = NULL, col2 = NULL, cols = NULL)
dataTBD
col1TBD
col2TBD
colsTBD
vector of indices Clear TestSet
clearTestSet()
Code$clearTestSet()
NULL Concatenate Expressions
concat()
Code$concat()
character of concatenated expressions Get Value
getValue()
Code$getValue(wh)
whcharacter
value stored at wh Set Value
setValue()
Code$setValue(wh, val)
whcharacter
valobject
clone()
The objects of this class are cloneable with this method.
Code$clone(deep = FALSE)
deepWhether to make a deep clone.
Create a new CodeSet object
code.set(title = "", description = "", excerpts = c(), codes = c())code.set(title = "", description = "", excerpts = c(), codes = c())
title |
Title for the CodeSet |
description |
Description of the CodeSet |
excerpts |
Set of excerpts to use with the CodeSet |
codes |
Set of codes to attach to the CodeSet |
CodeSet object
data(RS.data) rs = RS.data code.set = code.set("Demo RS CodeSet", "CodeSet made for the demo", excerpts = rs$text, codes = c())data(RS.data) rs = RS.data code.set = code.set("Demo RS CodeSet", "CodeSet made for the demo", excerpts = rs$text, codes = c())
Object representing a set of codes
CodeSet object Create CodeSet
titleTitle of the CodeSet
callTBD
codeslist of Codes
descriptionString description of the set of codes to be included
excerptsCharacter vector of text excerpts to code (optional)
new()
CodeSet$new(title = "ne", description = NULL, excerpts = c(), codes = c())
titleTBD
descriptionTBD
excerptsTBD
codesTBD
CodeSet
clone()
The objects of this class are cloneable with this method.
CodeSet$clone(deep = FALSE)
deepWhether to make a deep clone.
data(RS.data) rs = RS.data code.set = code.set("Demo RS CodeSet", "CodeSet made for the demo", excerpts = rs$text, codes = c())data(RS.data) rs = RS.data code.set = code.set("Demo RS CodeSet", "CodeSet made for the demo", excerpts = rs$text, codes = c())
Create a code
create.code( name = "NewCode", definition = NULL, excerpts = NULL, type = "Regex", ... )create.code( name = "NewCode", definition = NULL, excerpts = NULL, type = "Regex", ... )
name |
Name of the code |
definition |
Definition of the Code |
excerpts |
Character vectore of excerpts to use for Coding |
type |
Character string representing the type of code (Default: "Regex") |
... |
Additional parameters |
Code object
data(RS.data) rs = RS.data # Generate a Code newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text)data(RS.data) rs = RS.data # Generate a Code newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text)
Find rows that differ within a data.frame or two vectors
differences(code = NULL, wh = "trainingSet", to = "computerSet")differences(code = NULL, wh = "trainingSet", to = "computerSet")
code |
Code object to search for differences |
wh |
Set to use as the base comparison |
to |
Set to compare wh to |
logical vector representing indices that are coded differently
vector of indices representing differences
Match a set of text excerpts against a set of regular expressions
expression.match(excerpts, expressions, names = list(NULL, "V1"))expression.match(excerpts, expressions, names = list(NULL, "V1"))
excerpts |
Character vector to match against |
expressions |
Character vector of expressions |
names |
Character vector to use for dimension names |
Matrix representing matched expressions
Handset indices
getHandSetIndices( codeToUse, handSetLength = 20, handSetBaserate = 0.2, unseen = F )getHandSetIndices( codeToUse, handSetLength = 20, handSetBaserate = 0.2, unseen = F )
codeToUse |
[TBD] |
handSetLength |
[TBD] |
handSetBaserate |
[TBD] |
unseen |
[TBD] |
Get indices to code
getHandSetIndices2( code, handSetLength = 20, handSetBaserate = 0.2, unseen = FALSE, this.set = NULL )getHandSetIndices2( code, handSetLength = 20, handSetBaserate = 0.2, unseen = FALSE, this.set = NULL )
code |
Code object |
handSetLength |
Number of excerpts to put into the test set |
handSetBaserate |
Minimum number of positives that should be in the test set |
unseen |
[TBD] |
this.set |
[TBD] |
Code object with an updated test set and computer set
Handcode a set of excerpts using a vector of expressions
handcode( code = NULL, excerpts = NULL, expressions = NULL, n = ifelse(is.null(this.set), 10, length(this.set)), baserate = 0.2, unseen = FALSE, this.set = NULL, results = NULL )handcode( code = NULL, excerpts = NULL, expressions = NULL, n = ifelse(is.null(this.set), 10, length(this.set)), baserate = 0.2, unseen = FALSE, this.set = NULL, results = NULL )
code |
Code object to handcode |
excerpts |
Excerpts to code (optional) |
expressions |
Expressions to code with (options) |
n |
Number of excerpts to handcode |
baserate |
Value between 0 and 1, inflates the baserate chosen excerpts to code, ensuring the number of positive at least equal to n * baserate |
unseen |
Logical or number Indicating additional excerpts with unseen words should be added. If TRUE (default), two words added or by 'number' |
this.set |
[TBD] |
results |
[TBD] |
Code
Run tests (kappa, rho) on the given Code
old_test( code, kappaThreshold = 0.65, baserateInflation = 0.2, type = c("training", "test") )old_test( code, kappaThreshold = 0.65, baserateInflation = 0.2, type = c("training", "test") )
code |
Code object to test |
kappaThreshold |
Threshold used for calculating rhoR::rho |
baserateInflation |
inflation rate to use when sampling handsets |
type |
vector indicating which stats should be calculated |
Code object with updated statistics property
Print a Code summary
## S3 method for class 'summary.Code' print(x, ...)## S3 method for class 'summary.Code' print(x, ...)
x |
list from summary() |
... |
Additional parameters |
Prints code summary
data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) summary(newcode)data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) summary(newcode)
Print the summary of a CodeSet
## S3 method for class 'summary.CodeSet' print(x, ...)## S3 method for class 'summary.CodeSet' print(x, ...)
x |
Summary of a CodeSet |
... |
Additional parameters |
prints summary
data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) code.set = code.set("Demo RS CodeSet", "CodeSet made for the demo", excerpts = rs$text, codes = c(newcode)) summary(code.set)data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) code.set = code.set("Demo RS CodeSet", "CodeSet made for the demo", excerpts = rs$text, codes = c(newcode)) summary(code.set)
Print a TestList summary
## S3 method for class 'summary.TestList' print(x, ...)## S3 method for class 'summary.TestList' print(x, ...)
x |
list from summary() |
... |
Additional parameters |
prints summary
data(RS.data) rs = RS.data newcode <- create.code("Data", expressions = c("number","data"), excerpts = rs$text) newcode <- handcode(newcode, this.set = 10:15, results = 0) newcode = test(code = newcode, kappa_threshold = 0.65) summary(newcode$statistics)data(RS.data) rs = RS.data newcode <- create.code("Data", expressions = c("number","data"), excerpts = rs$text) newcode <- handcode(newcode, this.set = 10:15, results = 0) newcode = test(code = newcode, kappa_threshold = 0.65) summary(newcode$statistics)
Creates an object for Regular Expression coding. No need to call this directly, create.code is a nice wrapper around this and any other types of Codes
RegexCode object Create RegexCode
ncodeR::Code -> RegexCode
expressionsCharacter vector of regular expressions
metadataTBD
new()
RegexCode$new(name, definition, ..., excerpts = NULL, expressions = NULL)
nameTBD
definitionTBD
...TBD
excerptsTBD
expressionsTBD
Process Code
process()
RegexCode$process(excerpts = self$excerpts)
excerptsOptions excerpts to code
Code results Add word
add()
RegexCode$add(word)
wordTo add to expressions
NULL Remove word
remove()
RegexCode$remove(word)
wordto remove
NULL Concatenate expressions
concat()
RegexCode$concat()
character of concatentated expressions
clone()
The objects of this class are cloneable with this method.
RegexCode$clone(deep = FALSE)
deepWhether to make a deep clone.
data(RS.data) rs = RS.data # Generate a Code newcode = RegexCode$new(name = "New Code", definition = "Some definition", excerpts = rs$text, expressions = c("number","data"))data(RS.data) rs = RS.data # Generate a Code newcode = RegexCode$new(name = "New Code", definition = "Some definition", excerpts = rs$text, expressions = c("number","data"))
Resolve differing results
resolve( code = NULL, trainingSet = NULL, computerSet = NULL, expressions = NULL, excerpts = NULL, ignored = NULL )resolve( code = NULL, trainingSet = NULL, computerSet = NULL, expressions = NULL, excerpts = NULL, ignored = NULL )
code |
Code to resolve coding differences |
trainingSet |
Optionally provide a trainingSet, default: code$trainingSet |
computerSet |
Optionally provide a computerSet, default: code$computerSet |
expressions |
Optionally provide a set of expressions, default: code$expressions |
excerpts |
Optionally provide a set of excerpts, default: code$excerpts |
ignored |
Optionally proivde a set of excerpts to ignore during the resolve cycle loop |
A dataset containing sample chat data from the Rescushell Virtual Internship
RS.dataRS.data
An object of class data.frame with 3824 rows and 20 columns.
Obtain summary of a Code object
## S3 method for class 'Code' summary(object, ...)## S3 method for class 'Code' summary(object, ...)
object |
Code to summarize |
... |
Additional parameters |
List of Code summary
data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) summary(newcode)data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) summary(newcode)
Obtain a summary of the CodeSet
## S3 method for class 'CodeSet' summary(object, ...)## S3 method for class 'CodeSet' summary(object, ...)
object |
CodeSet object |
... |
Additional parameters |
list containing description and Code summaries
data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) code.set = code.set("Demo RS CodeSet", "CodeSet made for the demo", excerpts = rs$text, codes = c(newcode)) summary(code.set)data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) code.set = code.set("Demo RS CodeSet", "CodeSet made for the demo", excerpts = rs$text, codes = c(newcode)) summary(code.set)
Obtain a summary of a Code's test results
## S3 method for class 'TestList' summary(object, ...)## S3 method for class 'TestList' summary(object, ...)
object |
TestList object of Code |
... |
Additional parameters |
list of Test summary
data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) newcode <- handcode(newcode, this.set = 10:15, results = 0) newcode = test(code = newcode, kappa_threshold = 0.65) summary(newcode$statistics)data(RS.data) rs = RS.data newcode = create.code(name = "Data", expressions = c("number","data"), excerpts = rs$text) newcode <- handcode(newcode, this.set = 10:15, results = 0) newcode = test(code = newcode, kappa_threshold = 0.65) summary(newcode$statistics)
Test code
test( code, kappa_threshold = 0.65, baserate_inflation = 0.2, ignore_warning = FALSE, ... )test( code, kappa_threshold = 0.65, baserate_inflation = 0.2, ignore_warning = FALSE, ... )
code |
TBD |
kappa_threshold |
TBD |
baserate_inflation |
TBD |
ignore_warning |
logical, when FALSE (default) verfies test set size before executing test |
... |
TBD |
code object
Unseen Words
unseen_words( code, unweighted = TRUE, include_handcoded = FALSE, exclude_matched_by = c("excerpts", "word") )unseen_words( code, unweighted = TRUE, include_handcoded = FALSE, exclude_matched_by = c("excerpts", "word") )
code |
Code object |
unweighted |
logical TRUE (default), binarized the document matrix, so multiple occurrences of single word in one line doesn't count multiple times |
include_handcoded |
logical FALSE (default), will not use words from the handcoded set. If TRUE, the handcoded set will be used |
exclude_matched_by |
character, either "excerpts" (default) or "word". "excerpts" will remove full excerpts that match an expression, "word" will remove words from WDM to not include in sum of excerpts |
Excerpts that contain unseen words