juliasilge / juliasilge.com

My blog, built with blogdown and Hugo :link:
https://juliasilge.com/
41 stars 27 forks source link

Understanding PCA using Stack Overflow data | Julia Silge #74

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Understanding PCA using Stack Overflow data | Julia Silge

A data science blog

https://juliasilge.com/blog/stack-overflow-pca/

PatoLocos commented 2 years ago

Hi Julia! Since Tidy.numeric is deprecated, how do you replace "tidy" downhere?

library(broom)

tidied_pca <- bind_cols(Tag = colnames(tags_scaled), tidy(tags_pca$rotation)) %>% gather(PC, Contribution, PC1:PC64)

tidied_pca

Thanks again for your help and btw are you coming someday to Europe? :-)

juliasilge commented 2 years ago

@PatoLocos Can you use the broom tidiers, like tidy(tags_pca, matrix = "rotation")?

library(broom)

x  <- matrix(rnorm(200), nrow = 20)
pc <- irlba::prcomp_irlba(x, n = 3)
tidy(pc, matrix = "rotation")
#> # A tibble: 30 × 3
#>    column    PC   value
#>     <int> <dbl>   <dbl>
#>  1      1     1 -0.575 
#>  2      1     2 -0.176 
#>  3      1     3 -0.175 
#>  4      2     1  0.126 
#>  5      2     2  0.146 
#>  6      2     3 -0.319 
#>  7      3     1 -0.349 
#>  8      3     2 -0.110 
#>  9      3     3 -0.0494
#> 10      4     1 -0.0242
#> # … with 20 more rows
#> # ℹ Use `print(n = ...)` to see more rows

Created on 2022-08-08 by the reprex package (v2.0.1)

PatoLocos commented 2 years ago

Hi, It worked fine. I guess no conferences then in Europe? here (Norway) we have the OsloUseR group, it will be such a privilige if you could come Julia! but usually the big conferences are in Sweden or Denmark. :-(

juliasilge commented 2 years ago

@PatoLocos I haven't traveled outside the US since before the pandemic but I am starting to maybe feel ready. We'll see!