-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathREADME.Rmd
120 lines (80 loc) · 4.17 KB
/
README.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# stminsights
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/cschwem2er/stminsights?branch=master&svg=true)](https://ci.appveyor.com/project/cschwem2er/stminsights)
[![CRAN status](https://www.r-pkg.org/badges/version/stminsights)](https://cran.r-project.org/package=stminsights)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/stminsights)](https://cran.r-project.org/package=stminsights)
```{r, include = FALSE}
#[![CRAN status](https://www.r-pkg.org/badges/version/stminsights)](https://cran.r-project.org/package=stminsights)
#[![CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/stminsights)](https://cran.rstudio.com/web/packages/stminsights/index.html)
```
<img src="man/figures/logo.png" width="800">
## A Shiny Application for Structural Topic Models
This app enables interactive validation, interpretation and visualization of [Structural Topic Models](https://www.structuraltopicmodel.com/) (STM). Stminsights is focused on making your life easier after fitting your STM models. In case you are not familiar with the STM [package](https://CRAN.R-project.org/package=stm), the corresponding vignette is an excellent starting point.
## How to Install
You can download and install the latest development version of stminsights by running ``devtools::install_github('cschwem2er/stminsights')``.
For Windows users installing from github requires proper setup of [Rtools](https://cran.r-project.org/bin/windows/Rtools/).
stminsights can also be installed from CRAN by running ``install.packages('stminsights')``.
## How to Use
After loading stminsights you can launch the shiny app in your browser:
```{r, eval = FALSE}
library(stminsights)
run_stminsights()
```
You can then upload a `.RData` file which should include:
- one or several `stm` objects.
- one or several `estimateEffect` objects.
- an object `out` which was used to fit your stm models.
As an example, the following code fits two models and estimates effects for the Political Blog Corpus. Afterwards, all objects required for stminsights are stored in `stm_poliblog5k.RData`.
```{r, eval = FALSE}
library(stm)
out <- list(documents = poliblog5k.docs,
vocab = poliblog5k.voc,
meta = poliblog5k.meta)
poli <- stm(documents = out$documents,
vocab = out$vocab,
data = out$meta,
prevalence = ~ rating * s(day),
K = 20)
prep_poli <- estimateEffect(1:20 ~ rating * s(day), poli,
meta = out$meta)
poli_content <- stm(documents = out$documents,
vocab = out$vocab,
data = out$meta,
prevalence = ~ rating + s(day),
content = ~ rating,
K = 15)
prep_poli_content <- estimateEffect(1:15 ~ rating + s(day), poli_content,
meta = out$meta)
save.image('stm_poliblog5k.RData')
```
After launching stminsights and uploading the file, all objects are automatically imported and you can select which models and effect estimates to analyze.
In addition to the shiny app, several helper functions are available, e.g. ``get_effects()`` for storing effect estimates in a tidy dataframe.
## How to Deploy on Shiny Server
To deploy stminsights to your own shiny server, place the file `app.R`, which is located at `inst/app` of this package, to a folder in your server directory and you should be good to go.
## Citation
Please cite stminsights if you use it for your publications:
```
Carsten Schwemmer (2024). stminsights: A Shiny Application for Inspecting
Structural Topic Models. R package version 0.4.3.
https://github.com/cschwem2er/stminsights
```
A BibTeX entry for LaTeX users is:
```
@Manual{,
title = {stminsights: A Shiny Application for Inspecting Structural Topic Models},
author = {Carsten Schwemmer},
year = {2024},
note = {R package version 0.4.3},
url = {https://github.com/cschwem2er/stminsights},
}
```