cnlp_utils_pca: Compute Principal Components and store as a Data Frame

View source: R/tools.R

cnlp_utils_pcaR Documentation

Compute Principal Components and store as a Data Frame

Description

Takes a matrix and returns a data frame with the top principal components extracted. This is a simple but powerful technique for visualizing a corpus of documents.

Usage

cnlp_utils_pca(x, k = 2, center = TRUE, scale = TRUE)

Arguments

x

a matrix object to pass to prcomp

k

integer. The number of components to include in the output.

center

logical. Should the data be centered?

scale

logical. Should the data be scaled? Note that this will need to be set to false if any columns in x are constant if center is also true.

Value

a data frame object containing the top k principal components of the data in x.


cleanNLP documentation built on Nov. 17, 2023, 1:06 a.m.