Skip to contents

Link topics and their probabilities back to the original data frame.

Usage

topics_link(data, probabilities)

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()
#> 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.298    0.476   0.226
#>  2     2 The 54th Annual Hispanic Da… https:… 2           0.244    0.578   0.178
#>  3     3 Pura Belpré Award Winners 1… https:… 3           0.367    0.367   0.267
#>  4     4 Awesome music by Arco Iris,… https:… 4           0.0208   0.646   0.333
#>  5     5 @Valley_Vikings Celebrating… https:… 5           0.196    0.490   0.314
#>  6     6 How cool is this? So sorry … https:… 6           0.111    0.361   0.528
#>  7     7 #RobertFrancis(Not Beto)O'R… https:… 7           0.574    0.185   0.241
#>  8     8 Just to clarify. This is my… https:… 8           0.540    0.206   0.254
#>  9     9 Don’t forget to join our HS… https:… 9           0.217    0.417   0.367
#> 10    10 Don’t forget to join our HS… https:… 10          0.406    0.362   0.232
#> # ℹ 90 more rows