Skip to contents

Create a Term Frequency-Inverse Document Frequency analysis

Usage

tm_tf_idf(df, var, text_var, clean_text = TRUE, ...)

tm_tf_idf_plot(tf_idf, N = 10)

Arguments

df

A data frame

var

Categorical variable by it's name (in characters) you want to cut by

text_var

Text variable you are interested in (in characters)

clean_text

Cleans text if TRUE

...

Further arguments to tm_clean_text

tf_idf

output of tm_tf_idf

N

Number of bigrams in the TF-IDF plot you want to visualize

Value

A data.frame with counts for tm_tf_idf or a ggplot object for tm_tf_idf_plot

Examples

library(janeaustenr)
library(ggplot2)
df <- austen_books()

tf_idf <- tm_tf_idf(df, var = "book", text_var = "text")

tm_tf_idf_plot(tf_idf, 15)