EVOLUTION-MANAGER
Edit File: tidy_svd.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) svd object masquerading as list</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_svd {broom}"><tr><td>tidy_svd {broom}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Tidy a(n) svd object masquerading as list</h2> <h3>Description</h3> <p>Broom tidies a number of lists that are effectively S3 objects without a class attribute. For example, <code><a href="../../stats/html/optim.html">stats::optim()</a></code>, <a href="../../base/html/svd.html">svd()</a> and <code><a href="../../akima/html/interp.html">akima::interp()</a></code> produce consistent output, but because they do not have a class attribute, they cannot be handled by S3 dispatch. </p> <p>These functions look at the elements of a list and determine if there is an appropriate tidying method to apply to the list. Those tidiers are themselves are implemented as functions of the form <code style="white-space: pre;">tidy_<function></code> or <code style="white-space: pre;">glance_<function></code> and are not exported (but they are documented!). </p> <p>If no appropriate tidying method is found, throws an error. </p> <h3>Usage</h3> <pre> tidy_svd(x, matrix = "u", ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A list with components <code>u</code>, <code>d</code>, <code>v</code> returned by <code><a href="../../base/html/svd.html">base::svd()</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="../../base/html/svd.html">base::svd()</a></code> </p> <p>Other svd tidiers: <code><a href="augment.prcomp.html">augment.prcomp</a>()</code>, <code><a href="tidy.prcomp.html">tidy.prcomp</a>()</code>, <code><a href="tidy_irlba.html">tidy_irlba</a>()</code> </p> <p>Other list tidiers: <code><a href="glance_optim.html">glance_optim</a>()</code>, <code><a href="list_tidiers.html">list_tidiers</a></code>, <code><a href="tidy_irlba.html">tidy_irlba</a>()</code>, <code><a href="tidy_optim.html">tidy_optim</a>()</code>, <code><a href="tidy_xyz.html">tidy_xyz</a>()</code> </p> <h3>Examples</h3> <pre> library(modeldata) data(hpc_data) mat <- scale(as.matrix(hpc_data[, 2:5])) s <- svd(mat) tidy_u <- tidy(s, matrix = "u") tidy_u tidy_d <- tidy(s, matrix = "d") tidy_d tidy_v <- tidy(s, matrix = "v") tidy_v library(ggplot2) library(dplyr) ggplot(tidy_d, aes(PC, percent)) + geom_point() + ylab("% of variance explained") tidy_u %>% mutate(class = hpc_data$class[row]) %>% ggplot(aes(class, value)) + geom_boxplot() + facet_wrap(~PC, scale = "free_y") </pre> <hr /><div style="text-align: center;">[Package <em>broom</em> version 0.7.0 <a href="00Index.html">Index</a>]</div> </body></html>