Link topics and their probabilities back to the original data frame.
Source:R/topic_functions.R
topics_link.Rd
Link topics and their probabilities back to the original data frame.
Arguments
- data
Original data used to make the document-term matrices.
- probabilities
Probabilities data frame exported from the explore_LDAs function.
Value
Data frame containing the original data with the corresponding probabilities for each of the topics found.
Examples
list_data <- SegmentR:::test_data()
#> removing stopwords
#> Making DTMs
#> making tuning grid
#> setting up LDAs
probabilities <- list_data$explore$probabilities[[1]]
data <- list_data$lda$data[[1]]
topics_link(data, probabilities)
#> # A tibble: 100 × 7
#> rowid message url_var message_id topic_1 topic_2 topic_3
#> <dbl> <chr> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 1 The 54th Annual Hispanic Da… https:… 1 0.391 0.287 0.322
#> 2 2 The 54th Annual Hispanic Da… https:… 2 0.430 0.301 0.269
#> 3 3 Pura Belpré Award Winners 1… https:… 3 0.0167 0.0667 0.917
#> 4 4 Awesome music Arco Iris, fi… https:… 4 0.431 0.137 0.431
#> 5 5 @Valley_Vikings Celebrating… https:… 5 0.373 0.255 0.373
#> 6 6 How cool ? So sorry missed … https:… 6 0.452 0.238 0.310
#> 7 7 #RobertFrancis(Not Beto)O'R… https:… 7 0.317 0.317 0.367
#> 8 8 Just clarify. This opinion.… https:… 8 0.275 0.362 0.362
#> 9 9 Don’t forget join HSA NSHS … https:… 9 0.217 0.417 0.367
#> 10 10 Don’t forget join HSA NSHS … https:… 10 0.319 0.319 0.362
#> # ℹ 90 more rows