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.
cnlp_utils_pca(x, k = 2, center = TRUE, scale = TRUE)
a data frame object containing the top k
principal
components of the data in x.
a matrix object to pass to prcomp
integer. The number of components to include in the output.
logical. Should the data be centered?
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.