politenessPlot {politeness} | R Documentation |
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,
features = NULL,
ordered = FALSE,
CI = 0.68
)
Arguments
df_polite |
a data.frame with politeness features calculated from a document set, as output by |
split |
a vector of covariate values. must have a length equal to the number of documents included in |
split_levels |
character vector of length 2 default NULL. Labels for covariate levels for legend. If NULL, this will be inferred from |
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 |
middle_out |
Features less distinctive than this value (measured by p-value of t-test) are excluded. Defaults to 1 (i.e. include all). |
features |
character vector of feature names. If NULL all will be included. |
ordered |
logical should features be ordered according to features param? default is FALSE. |
CI |
Coverage of error bars. Defaults to 0.68 (i.e. standard error). |
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).
Value
a ggplot of the prevalence of politeness features, conditional on split
. Features are sorted by variance-weighted log odds ratio.
Examples
data("phone_offers")
polite.data<-politeness(phone_offers$message, parser="none", drop_blank=FALSE)
politeness::politenessPlot(polite.data,
split=phone_offers$condition,
split_levels = c("Tough","Warm"),
split_name = "Condition",
top_title = "Average Feature Counts")
politeness::politenessPlot(polite.data,
split=phone_offers$condition,
split_levels = c("Tough","Warm"),
split_name = "Condition",
top_title = "Average Feature Counts",
features=c("Positive.Emotion","Hedges","Negation"))
polite.data<-politeness(phone_offers$message, parser="none", metric="binary", drop_blank=FALSE)
politeness::politenessPlot(polite.data,
split=phone_offers$condition,
split_levels = c("Tough","Warm"),
split_name = "Condition",
top_title = "Binary Feature Use")