dfm_scaling_test: Comparison of dfms using N-dimensional scaling, with a test...

Description Usage Arguments Value Examples

View source: R/dfm_scaling_test.R

Description

Scale each dfm into a N-d space and test for outliers.

Usage

1
2
3
4
5
6
7
8
dfm_scaling_test(
  scaling_results,
  labels,
  dimensions = 2,
  distance_method = "cosine",
  method = c("distances", "positions"),
  return_positions = FALSE
)

Arguments

scaling_results

A list object produced by the 'scaling_comparison()' function.

labels

A character vector with labels for each dfm. This can be extracted from the '$labels' field of the output from the 'factorial_preprocessing()' function.

dimensions

The number of dimensions to be used by the multidimensional scaling algorithm. Defaults to 2.

distance_method

The method that should be used for calculating distances between dfms. Defaults to "cosine".

method

Should the raw distances or scaled document positions be used for scaling? Can be one of c("distances","positions"), defaults to "distances".

return_positions

Logical indicating whether dfm positions should be returned as a data.frame. Defaults to FALSE

Value

A result list object, or a plot, or both.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## 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)
# now perform the scaling test
dfm_scaling_test(scaling_results,
                 labels = preprocessed_documents$labels)

## End(Not run)

matthewjdenny/preText documentation built on July 27, 2021, 1:18 a.m.