widely_svd | R Documentation |
This is useful for dimensionality reduction of items, especially when setting a lower nv.
widely_svd(tbl, item, feature, value, nv = NULL, weight_d = FALSE, ...) widely_svd_(tbl, item, feature, value, nv = NULL, weight_d = FALSE, ...)
tbl |
Table |
item |
Item to perform dimensionality reduction on; will end up in |
feature |
Column describing the feature that links one item to others. |
value |
Value |
nv |
Optional; the number of principal components to estimate. Recommended for matrices with many features. |
weight_d |
Whether to multiply each value by the |
... |
Extra arguments passed to |
A tbl_df with three columns. The first is retained from the item
input,
then dimension
and value
. Each row represents one principal component
value.
library(dplyr) library(gapminder) # principal components driving change gapminder_svd <- gapminder %>% widely_svd(country, year, lifeExp) gapminder_svd # compare SVDs, join with other data library(ggplot2) library(tidyr) gapminder_svd %>% spread(dimension, value) %>% inner_join(distinct(gapminder, country, continent), by = "country") %>% ggplot(aes(`1`, `2`, label = country)) + geom_point(aes(color = continent)) + geom_text(vjust = 1, hjust = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.