document_position_plots: Document Position Plots

Description Usage Arguments Value Examples

View source: R/document_position_plots.R

Description

Plot Procrustes transformed scaled positions of each document under each preprocessing regime.

Usage

1
2
3
4
5
6
document_position_plots(
  positions_list,
  num_cols = 10,
  colors = NULL,
  decision_colors = NULL
)

Arguments

positions_list

A list of scaled document positions generated by the 'scaling_comparison()' and returned in the '$scaled_positions' field.

num_cols

The number of columns to use in combining plots into a a large tiled plot..

colors

Optional vector of document colors to distinguish groups.

decision_colors

Defaults to NULL, if desired, the user should provide a vector of logical values of length equal to the number of preprocessing decisions. Can be used to bifurcate the points within a single plot to show the effects of a particular decision. Points in the TRUE class will be colors BLUE and those in the FALSE class will be colored red.

Value

A list of ggplot2 objects.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
# *** This function is used automatically inside of the preText() function.
# load the package
library(preText)
# load in the data
data("UK_Manifestos")
# preprocess data
preprocessed_documents <- factorial_preprocessing(
    UK_Manifestos,
    use_ngrams = TRUE,
    infrequent_term_threshold = 0.02,
    verbose = TRUE)
# scale documents
scaling_results <- scaling_comparison(preprocessed_documents$dfm_list,
                                      dimensions = 2,
                                      distance_method = "cosine",
                                      verbose = TRUE)
# plot scaled positions
document_position_plots(scaling_results$scaled_positions,
                        num_cols = 10,
                        colors = NULL,
                        decision_colors = NULL)

## End(Not run)

matthewjdenny/preptest documentation built on July 27, 2021, 1:19 a.m.