Type: | Package |
Title: | Text Annotation App |
Version: | 0.1.2 |
Description: | Shiny-App that allows to annotate vectors of texts to predefined categories by hand. |
License: | Apache License (≥ 2.0) |
URL: | https://github.com/liserman/handcodeR/ |
BugReports: | https://github.com/liserman/handcodeR/issues |
Imports: | shiny (≥ 1.7.0), shinyWidgets (≥ 0.7.6) |
Suggests: | testthat (≥ 3.0.0), shinytest2(≥ 0.2.0) |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.3 |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2023-10-24 18:02:34 UTC; liserman |
Author: | Lukas Isermann |
Maintainer: | Lukas Isermann <lukas.isermann@uni-mannheim.de> |
Repository: | CRAN |
Date/Publication: | 2023-10-24 20:20:02 UTC |
button_output: Formatting of output for shiny::radioButtons
Description
'button_output' is an internal function to 'handcode'. It works within the Shiny-App 'handcoder_app' to format the look of the shiny::radioButtons.
Usage
button_output(classification, button, names = FALSE)
Arguments
classification |
Classification list obtained as list item from 'data_for_app' |
button |
Numerical value indicating for which button names and labels should be returned |
names |
Logical value indicating whether the function is supposed to return a formatted list of labels or a vector of names for use in radioButtons. |
Value
Depending on the logical names input, the function returns a list of HTML formatted labels or the list of category names for the display of the radioButtons in the Shiny-App.
character_to_data: Transform text vector and arg_list to data frame.
Description
'character_to_data' is an internal function to 'handcode'. It takes a character vector of texts as well as an arg_list of named character vectors as inputs and returns a data frame which can be used as input to 'data_for_app'.
Usage
character_to_data(data, arg_list, missing)
Arguments
data |
A character vector of texts which has been given as data input to 'handcode'. |
arg_list |
A list of additional arguments which have been given as input to 'handcode'. These must be named character vectors of categories that will be used to annotate the given texts. |
missing |
A character vector of values that are displayed as missing values in the App. In the return data, these missing will be saved with an additional "_" as prefix and suffix. |
Value
The function returns a data frame in the format of the output data frame that can be processed by the handcode() function.
data_for_app: Prepare inputs for Shiny-App
Description
'data_for_app' is an internal function to 'handcode'. It takes the inputs data, start, randomize and context to generate a list of inputs which can then be passed to 'handcoder_app'.
Usage
data_for_app(data, start, randomize, context, pre = NULL, post = NULL)
Arguments
data |
A data frame that has been prepared by 'character_to_data' or that has previously already been returned from 'handcode'. |
start |
The value that has been given as start value to 'handcode'. |
randomize |
The logical value that has been given as randomize to 'handcode'. |
context |
The logical value that has been given as context to 'handcode'. |
pre |
Optional vector of texts that come before each respective text to be coded. |
post |
Optional vector of texts that come after each respective text to be coded. |
Value
The function returns a list of inputs needed within the Shiny-App.
gen_output: Combine data and values of Shiny-App to output
Description
'gen_output' is an internal function to 'handcode'. It works within the Shiny-App 'handcoder_app' to prepare the output data frame.
Usage
gen_output(data, values)
Arguments
data |
The data frame initially passed to 'handcoder_app' within a. |
values |
The values generated by the server of the 'handcoder_app'. |
Value
The function returns a data frame with the coded variables.
handcode: Classifying text into pre-defined categories.
Description
'handcode' opens a Shiny-App which allows for hand coding strings of text into pre-defined categories. You can code between one and three variables at a time. It returns an updated data frame with your annotated classifications.
Usage
handcode(
data,
...,
start = "first_empty",
randomize = FALSE,
context = FALSE,
missing = c("Not applicable"),
pre = NULL,
post = NULL
)
Arguments
data |
A character vector of texts you want to annotate or a data frame returned from the handcode() function. |
... |
Between one and six named character vectors indicating different variables and categories you want to use for your annotation. Only needed if data a new character vector of texts. |
start |
A numeric value indicating the line in which you want to start hand coding. Alternatively, you can set start to "first_empty" to automatically start hand coding in the first line that has not been coded yet, or to "all_empty" to display all lines that have not been coded yet. |
randomize |
A logical value indicating whether you want to randomize the order in which texts are shown to the coder. |
context |
A logical value indicating whether you want the coder to see the previous and next text alongside the text that is currently coded. If TRUE, the function will show the previous and next text in light gray. This option is especially useful if we annotate individual sentences within a larger document. |
missing |
A character vector of values that are displayed as missing values in the App. In the return data, these missing will be saved with an additional "_" as prefix and suffix. |
pre |
Optional vector of custom texts that come as previous text before each respective text to be coded. Will be displayed if context = TRUE. This option can be used if the vector of texts specified in data do not form a continuous text. |
post |
Optional vector of custom texts that come as next text after each respective text to be coded. Will be displayed if context = TRUE. This option can be used if the vector of texts specified in data do not form a continuous text. |
Value
The function returns a data frame containing all annotations that have been made in the Shiny-App.
Examples
reviews <- c("Good Quality Dog Food",
"Not as Advertised",
"Delight says it all",
"Great! Just as good as the expensive brands")
annotated <- handcode(reviews, evaluation = c("positive", "negative"))
handcoder_app: App to classify text snippets
Description
'handcoder_app' is an internal function to 'handcode'. It provides a Shiny-App that allows users to click through different snippets of text and classify them manually according to predefined categories.
Usage
handcoder_app(a)
Arguments
a |
A list containing all relevant information for the app to function. The list will be automatically generated by 'data_for_app'. |
Value
The Shiny-App returns a data frame with the coded variables.