EVOLUTION-MANAGER
Edit File: tidy.prcomp.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Tidy a(n) prcomp object</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for tidy.prcomp {broom}"><tr><td>tidy.prcomp {broom}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Tidy a(n) prcomp object</h2> <h3>Description</h3> <p>Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return. </p> <h3>Usage</h3> <pre> ## S3 method for class 'prcomp' tidy(x, matrix = "u", ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A <code>prcomp</code> object returned by <code><a href="../../stats/html/prcomp.html">stats::prcomp()</a></code>.</p> </td></tr> <tr valign="top"><td><code>matrix</code></td> <td> <p>Character specifying which component of the PCA should be tidied. </p> <ul> <li> <p><code>"u"</code>, <code>"samples"</code>, <code>"scores"</code>, or <code>"x"</code>: returns information about the map from the original space into principle components space. </p> </li> <li> <p><code>"v"</code>, <code>"rotation"</code>, <code>"loadings"</code> or <code>"variables"</code>: returns information about the map from principle components space back into the original space. </p> </li> <li> <p><code>"d"</code>, <code>"eigenvalues"</code> or <code>"pcs"</code>: returns information about the eigenvalues. </p> </li></ul> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Additional arguments. Not used. Needed to match generic signature only. <strong>Cautionary note:</strong> Misspelled arguments will be absorbed in <code>...</code>, where they will be ignored. If the misspelled argument has a default value, the default value will be used. For example, if you pass <code>conf.lvel = 0.9</code>, all computation will proceed using <code>conf.level = 0.95</code>. Additionally, if you pass <code>newdata = my_tibble</code> to an <code><a href="reexports.html">augment()</a></code> method that does not accept a <code>newdata</code> argument, it will use the default value for the <code>data</code> argument.</p> </td></tr> </table> <h3>Details</h3> <p>See https://stats.stackexchange.com/questions/134282/relationship-between-svd-and-pca-how-to-use-svd-to-perform-pca for information on how to interpret the various tidied matrices. Note that SVD is only equivalent to PCA on centered data. </p> <h3>Value</h3> <p>A <a href="../../tibble/html/tibble.html">tibble::tibble</a> with columns depending on the component of PCA being tidied. </p> <p>If <code>matrix</code> is <code>"u"</code>, <code>"samples"</code>, <code>"scores"</code>, or <code>"x"</code> each row in the tidied output corresponds to the original data in PCA space. The columns are: </p> <table summary="R valueblock"> <tr valign="top"><td><code><code>row</code></code></td> <td> <p>ID of the original observation (i.e. rowname from original data).</p> </td></tr> <tr valign="top"><td><code><code>PC</code></code></td> <td> <p>Integer indicating a principal component.</p> </td></tr> <tr valign="top"><td><code><code>value</code></code></td> <td> <p>The score of the observation for that particular principal component. That is, the location of the observation in PCA space.</p> </td></tr> </table> <p>If <code>matrix</code> is <code>"v"</code>, <code>"rotation"</code>, <code>"loadings"</code> or <code>"variables"</code>, each row in the tidied output corresponds to information about the principle components in the original space. The columns are: </p> <table summary="R valueblock"> <tr valign="top"><td><code><code>row</code></code></td> <td> <p>The variable labels (colnames) of the data set on which PCA was performed</p> </td></tr> <tr valign="top"><td><code><code>PC</code></code></td> <td> <p>An integer vector indicating the principal component</p> </td></tr> <tr valign="top"><td><code><code>value</code></code></td> <td> <p>The value of the eigenvector (axis score) on the indicated principal component</p> </td></tr> </table> <p>If <code>matrix</code> is <code>"d"</code>, <code>"eigenvalues"</code> or <code>"pcs"</code>, the columns are: </p> <table summary="R valueblock"> <tr valign="top"><td><code><code>PC</code></code></td> <td> <p>An integer vector indicating the principal component</p> </td></tr> <tr valign="top"><td><code><code>std.dev</code></code></td> <td> <p>Standard deviation explained by this PC</p> </td></tr> <tr valign="top"><td><code><code>percent</code></code></td> <td> <p>Fraction of variation explained by this component</p> </td></tr> <tr valign="top"><td><code><code>cumulative</code></code></td> <td> <p>Cumulative fraction of variation explained by principle components up to this component.</p> </td></tr> </table> <h3>See Also</h3> <p><code><a href="../../stats/html/prcomp.html">stats::prcomp()</a></code>, <a href="tidy_svd.html">svd_tidiers</a> </p> <p>Other svd tidiers: <code><a href="augment.prcomp.html">augment.prcomp</a>()</code>, <code><a href="tidy_irlba.html">tidy_irlba</a>()</code>, <code><a href="tidy_svd.html">tidy_svd</a>()</code> </p> <h3>Examples</h3> <pre> pc <- prcomp(USArrests, scale = TRUE) # information about rotation tidy(pc) # information about samples (states) tidy(pc, "samples") # information about PCs tidy(pc, "pcs") # state map library(dplyr) library(ggplot2) pc %>% tidy(matrix = "samples") %>% mutate(region = tolower(row)) %>% inner_join(map_data("state"), by = "region") %>% ggplot(aes(long, lat, group = group, fill = value)) + geom_polygon() + facet_wrap(~PC) + theme_void() + ggtitle("Principal components of arrest data") au <- augment(pc, data = USArrests) au ggplot(au, aes(.fittedPC1, .fittedPC2)) + geom_point() + geom_text(aes(label = .rownames), vjust = 1, hjust = 1) </pre> <hr /><div style="text-align: center;">[Package <em>broom</em> version 0.7.0 <a href="00Index.html">Index</a>]</div> </body></html>