1

I am using the quanteda package in r for textual data analysis. I am interested in plotting some Keyword-in-context display using the kwic() command that is to useful to find multi-word expressions in tokens.

# Remove punctuation and symbols 
toks_comments <- tokens(comments_corpus, remove_punct = TRUE, remove_symbols = TRUE, padding = 
TRUE) %>% 
tokens_remove(stopwords("spanish"), padding = TRUE)


# Get relevant keywords and phrases from dictionary
servicio <- 
c("servicio","atencion","atención","personal","mesera","mesero","muchacha","muchacho","joven",
         "pelado", "pelada","meseros")

# Keyword-in-context
servicio_context <- kwic(toks_comments, pattern = phrase(servicio))  
View(servicio_context)

Once the previous lines have been run, I get the result that I have included in the photo. From that table in the photo, I am interested in graphing the "pre" and "post" column but I don't know how to do it. Is there a way to include the words in a multiword wordcloud or some other frequency visualization?

Here is the pic:"View(servicio_context)"

1 Answer 1

0

You could do both a wordcloud and a frequency bar graph.

Wordcloud

library(quanteda.textplots)
library(quanteda)

dfm(servicio_context$pre) %>%
  textplot_wordcloud()

Bar Graph

library(ggplot2)

servicio_context %>%
  ggplot(aes(x = pre)) +
  geom_bar(stat = "count")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.