idiosync_response_words: Idiosyncratic Response Words

Description Usage Arguments Details Value See Also Examples

View source: R/idiosync.R

Description

This function identifies response words that are idiosyncratic (i.e. appear multiple times in a single response, and not in any other responses). It can also be used to remove these words.

Usage

1
2
3
4
5
6
idiosync_response_words(
  inputDataframe,
  mode,
  textColumnName,
  participantColumnName
)

Arguments

inputDataframe

A dataframe containing a column with text data (character strings)

mode

This defines the mode of operation. Options include "output", "remove", or "both". See Details below.

textColumnName

A string consisting of the name of the column in inputDataframe which contains text data

participantColumnName

(Optional argument) A string consisting of the name of the column in inputDataframe which contains participant IDs

Details

This function has three modes: In the "output" mode, a dataframe is produced with three columns: the response with idiosyncratic words, the words, and how frequently they appear in that response. If a participantColumnName is provided, a fourth column with participant IDs is included. In the "remove" mode, a character string (or vector of character strings) is produced, where all of the idiosyncratic words are removed. In the "both" mode, both of the above results will be produced (i.e. a list containing a dataframe of idiosyncratic words, as well as the text with those words removed)

Value

A dataframe (mode="output"), a character string or vector of character strings (mode="remove"), or a two-object list containing both results (mode="both")

See Also

idiosync_participant_words

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
myStrings = c("I like going to the park. The park is one of my favorite places to visit.",
              "Today is really rainy, but I'm a fan of this kind of weather to be honest.",
              "Yesterday, a bright red car with shiny red wheels drove past the house.")
mydataframe = data.frame(text=myStrings, stringsAsFactors = FALSE)
idiosync_output = idiosync_response_words(mydataframe, textColumnName = "text", mode = "output")
idiosync_output
# response_number     feature       frequency
# 1                   park          2
# 3                   red           2

idiosync_removed = idiosync_response_words(mydataframe, textColumnName = "text", mode = "remove")
idiosync_removed
# "I like going to the. The is one of my favorite places to visit."
# "Today is really rainy, but I'm a fan of this kind of weather to be honest."
# "Yesterday, a bright car with shiny wheels drove past the house."

nlanderson9/languagePredictR documentation built on June 10, 2021, 11 a.m.