-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC.2 table_topic.R
42 lines (32 loc) · 1.23 KB
/
C.2 table_topic.R
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
rm(list = ls())
#load and initialize data
tmp <- read.csv(file = "outputs/stmoutput_filt_50.csv")
tbl <- tmp[, c("label", "gamma")]
#remove unwanted topics
pos_rm <- which(tbl$label == "Remainder 2" |
tbl$label == "Remainder 1" |
tbl$label == "Financial Literature Analysis" |
tbl$label == "Literature Reviews" |
tbl$label == "Statistical Modeling")
#generate table
tbl <- tbl[-pos_rm, ]
tbl <- tbl[order(tbl$gamma, decreasing = TRUE), ]
tbl$gamma <- round(tbl$gamma * 100, 2)
tbl$label <- paste0("\\textsf{", tbl$label, "}", sep = "")
rownames(tbl) <- NULL
tbl
print(xtable::xtable(tbl),
include.rownames = FALSE,
sanitize.text.function = identity,
file = "tables/tbl_2_topic.txt")
# get option pricing only part for text
stm_outputs <- readRDS("outputs/stmoutput_filt_50.rds")
beta <- stm_outputs$beta[[1]][[1]]
dim(beta)
tmp <- read.csv(file = "outputs/stmoutput_filt_50.csv")
pos <- which(tmp$label == "Option Pricing")
pos2 <- order(beta[pos, ], decreasing = TRUE)[1:10]
round(100 * exp(beta[pos, pos2]), 2)
tmp$terms <- stringr::str_replace_all(tmp$terms, " ", "\\\\_")
tmp$terms <- stringr::str_replace_all(tmp$terms, ",\\\\_", ", ")
tmp$terms[pos]