Learn R Programming

politeness (version 0.2.2)

politenessPlot: Politeness plot

Description

Plots the prevalence of politeness features in documents, divided by a binary covariate.

Usage

politenessPlot(df_polite, split = NULL, split_levels = NULL,
  split_name = NULL, split_cols = c("firebrick", "navy"), top_title = "",
  drop_blank = 0.05, middle_out = 0.5)

Arguments

df_polite

a data.frame with politeness features calculated from a document set, as output by politeness.

split

a vector of covariate values. must have a length equal to the number of documents included in df_polite.

split_levels

character vector of length 2 default NULL. Labels for covariate levels for legend. If NULL, this will be inferred from split.

split_name

character default NULL. Name of the covariate for legend.

split_cols

character vector of length 2. Name of colors to use.

top_title

character default "". Title of plot.

drop_blank

Features less prevalent than this in the sample value are excluded from the plot. To include all features, set to 0

middle_out

Features less distinctive than this value (measured by p-value of t-test) are excluded. Defaults to 1 (i.e. include all).

Value

a ggplot of the prevalence of politeness features, conditional on split. Features are sorted by variance-weighted log odds ratio.

Details

Length of split must be the same as number of rows of df_polite. Typically split should be a two-category variable. However, if a continuous covariate is given, then the top and bottom terciles of that distribution are treated as the two categories (while dropping data from the middle tercile).

Examples

Run this code
# NOT RUN {
data("phone_offers")

polite.data<-politeness(phone_offers$message, parser="none", binary=FALSE, drop_blank=FALSE)

politeness::politenessPlot(polite.data,
                           split=phone_offers$condition,
                           split_levels = c("Tough","Warm"),
                           split_name = "Condition",
                           top_title = "Average Feature Counts")


polite.data<-politeness(phone_offers$message, parser="none", binary=TRUE, drop_blank=FALSE)

politeness::politenessPlot(polite.data,
                           split=phone_offers$condition,
                           split_levels = c("Tough","Warm"),
                           split_name = "Condition",
                           top_title = "Binary Feature Use")

# }

Run the code above in your browser using DataLab