Skip to content

Commit

Permalink
Fix #7 in textplot_bitermclusters.default which could unintentionally…
Browse files Browse the repository at this point in the history
… have behaviour which depends on the order of the data
  • Loading branch information
jwijffels committed Oct 12, 2021
1 parent d0c40fb commit 6597170
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: textplot
Type: Package
Title: Text Plots
Version: 0.2.0
Version: 0.2.1
Maintainer: Jan Wijffels <[email protected]>
Authors@R: c(
person('Jan', 'Wijffels', role = c('aut', 'cre', 'cph'), email = '[email protected]'),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## CHANGES IN textplot VERSION 0.2.1

- Fix bug in textplot_bitermclusters.default (and plot.BTM as it uses textplot_bitermclusters.default) which
unintentionally left the option open that if a biterm which was assigned to several topics it could be shown in one of the 2 topics by chance depending on the order of the biterms data. This could only occur if the most emitted words by each of these 2 topics were the same. See issue #7.

## CHANGES IN textplot VERSION 0.2.0

- Added textplot_embedding_2d
Expand Down
2 changes: 1 addition & 1 deletion R/textplot_biterms.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ textplot_bitermclusters.default <- function(x, biterms,
if(!missing(which)){
biterms <- biterms[biterms$topic %in% which, ]
}
biterms <- biterms[, topic_freq := .N, by = list(term1, term2)]
biterms <- biterms[, topic_freq := .N, by = list(term1, term2, topic)]
biterms <- biterms[, list(best_topic = topic[which.max(topic_freq)], cooc = .N), by = list(term1, term2)]
# biterms <- biterms[, list(best_topic = utils::head(base::names(base::sort(base::table(topic), decreasing = TRUE)), 1),
# cooc = .N), by = list(term1, term2)]
Expand Down

0 comments on commit 6597170

Please sign in to comment.