I have this automated script that produces a table with frequencies of "thetarget" tokens by year:
library(quanteda)
vec <- c("Apple", "Google")
out <- map(vec, ~
df %>%
filter(str_detect(collectionName, .x)) %>%
filter(str_detect(Year, paste(years, collapse = "|"))) %>%
corpus(text_field = "text") %>%
tokens() %>%
tokens_select(thetarget) %>%
dfm() %>%
dfm_group(groups = "Year") %>%
convert(to = "data.frame")
)
names(out) <- sub("^(...).*\\s+(\\S)$", "\\1\\2", vec)
Using
View(out$Apple)
Produces the corresponding table.
I am trying to automate the export of these tables as a pdf or jpeg with the name of the file being "Apple" for example.
Is there a way to do this?
TIA