-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpca_text_example.Rmd
83 lines (65 loc) · 1.43 KB
/
pca_text_example.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
title: "PCA R Packages"
author: "Karl Rohe"
date: "2024-01-15"
output: html_document
editor_options:
chunk_output_type: console
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
```{r, include=FALSE}
#> r = getOption("repos")
#> r["CRAN"] = "http://cran.us.r-project.org"
#> options(repos = r)
```
```{r, cache=TRUE}
library(tidyverse)
library(longpca)
#> all_packages = available.packages() %>% as_tibble()
all_packages
top_packages
```
```{r}
im_description = make_interaction_model(~Package*Description, top_packages, parse_text = TRUE, to_lower= TRUE)
diagnose(im_description)
dimcv = pick_dim(im_description, 20,num_bootstraps = 10)
plot(dimcv)
dimcv
pcs = pca(im_description, 6)
streaks(pcs)
spcs = rotate(pcs)
streaks(spcs)
streaks(spcs,"cols")
top(spcs,2)
top(spcs,3)
top(spcs,4)
top(spcs,5)
```
```{r}
im_authors = make_interaction_model(~Package*Author, top_packages, parse_text = TRUE, to_lower= TRUE)
im_authors
diagnose(im_authors)
dimcv = pick_dim(im_authors, 20,num_bootstraps = 10)
plot(dimcv)
dimcv
pcs_authors = pca(im_authors, 10)
streaks(pcs_authors)
spcs_authors = rotate(pcs_authors)
streaks(spcs_authors)
streaks(spcs_authors, "cols")
```
```{r}
sptext = make_interaction_model(~Package*Imports, all_packages, parse_text = TRUE)
```
```{r, cache = TRUE}
diagnose(sptext)
pcs = pca_text(1~Package*Imports, all_packages, k = 10)
spcs = rotate(pcs)
top(pcs,1)
top(spcs,1)
```