Learn R Programming

cleanNLP (version 3.0.7)

cnlp_utils_pca: 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)

Value

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

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.