Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CRAN issues #24

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: quanteda.textplots
Title: Plots for the Quantitative Analysis of Textual Data
Version: 0.94.3
Version: 0.94.4
Authors@R:
c(
person("Kenneth", "Benoit", email = "[email protected]", role = c("cre", "aut", "cph"), comment = c(ORCID = "0000-0002-0797-564X")),
Expand Down Expand Up @@ -44,4 +44,4 @@ Encoding: UTF-8
BugReports: https://github.com/quanteda/quanteda.textplots/issues
Language: en-GB
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
16 changes: 8 additions & 8 deletions R/textplot_keyness.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
#' \dontrun{
#' library("quanteda")
#' # compare Trump speeches to other Presidents by chi^2
#' dfmat1 <- data_corpus_inaugural %>%
#' corpus_subset(Year > 1980) %>%
#' tokens(remove_punct = TRUE) %>%
#' tokens_remove(stopwords("en")) %>%
#' dfmat1 <- data_corpus_inaugural |>
#' corpus_subset(Year > 1980) |>
#' tokens(remove_punct = TRUE) |>
#' tokens_remove(stopwords("en")) |>
#' dfm()
#' dfmat1 <- dfm_group(dfmat1, groups = dfmat1$President)
#' tstat1 <- quanteda.textstats::textstat_keyness(dfmat1, target = "Trump")
Expand All @@ -39,13 +39,13 @@
#' textplot_keyness(tstat1, margin = 0.2, n = 10)
#'
#' # compare contemporary Democrats v. Republicans
#' corp <- data_corpus_inaugural %>%
#' corp <- data_corpus_inaugural |>
#' corpus_subset(Year > 1960)
#' corp$party <- ifelse(docvars(corp, "President") %in% c("Nixon", "Reagan", "Bush", "Trump"),
#' "Republican", "Democrat")
#' dfmat2 <- corp %>%
#' tokens(remove_punct = TRUE) %>%
#' tokens_remove(stopwords("en")) %>%
#' dfmat2 <- corp |>
#' tokens(remove_punct = TRUE) |>
#' tokens_remove(stopwords("en")) |>
#' dfm()
#' tstat2 <- quanteda.textstats::textstat_keyness(dfm_group(dfmat2, groups = dfmat2$party),
#' target = "Democrat", measure = "lr")
Expand Down
21 changes: 12 additions & 9 deletions R/textplot_network.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,22 @@
#' @examples
#' set.seed(100)
#' library("quanteda")
#' toks <- data_char_ukimmig2010 %>%
#' tokens(remove_punct = TRUE) %>%
#' tokens_tolower() %>%
#' toks <- data_char_ukimmig2010 |>
#' tokens(remove_punct = TRUE) |>
#' tokens_tolower() |>
#' tokens_remove(pattern = stopwords("english"), padding = FALSE)
#' fcmat <- fcm(toks, context = "window", tri = FALSE)
#' feat <- names(topfeatures(fcmat, 30))
#' fcm_select(fcmat, pattern = feat) %>%
#' feat <- colSums(fcmat) |>
#' sort(decreasing = TRUE) |>
#' head(30) |>
#' names()
#' fcm_select(fcmat, pattern = feat) |>
#' textplot_network(min_freq = 0.5)
#' fcm_select(fcmat, pattern = feat) %>%
#' fcm_select(fcmat, pattern = feat) |>
#' textplot_network(min_freq = 0.8)
#' fcm_select(fcmat, pattern = feat) %>%
#' fcm_select(fcmat, pattern = feat) |>
#' textplot_network(min_freq = 0.8, vertex_labelcolor = rep(c('gray40', NA), 15))
#' fcm_select(fcmat, pattern = feat) %>%
#' fcm_select(fcmat, pattern = feat) |>
#' textplot_network(vertex_labelsize = 10)
#' fcm_30 <- fcm_select(fcmat, pattern = feat)
#' textplot_network(fcm_30,
Expand Down Expand Up @@ -198,7 +201,7 @@ as.igraph <- function(x, ...) UseMethod("as.igraph")
#' # as.igraph
#' if (requireNamespace("igraph", quietly = TRUE)) {
#' txt <- c("a a a b b c", "a a c e", "a c e f g")
#' mat <- fcm(txt)
#' mat <- fcm(tokens(txt))
#' as.igraph(mat, min_freq = 1, omit_isolated = FALSE)
#' }
as.igraph.fcm <- function(x, min_freq = 0.5, omit_isolated = TRUE, ...) {
Expand Down
30 changes: 14 additions & 16 deletions R/textplot_wordcloud.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
#' # plot the features (without stopwords) from Obama's inaugural addresses
#' set.seed(10)
#' library("quanteda")
#' dfmat1 <- data_corpus_inaugural %>%
#' corpus_subset(President == "Obama") %>%
#' tokens(remove_punct = TRUE) %>%
#' tokens_remove(stopwords("en")) %>%
#' dfm() %>%
#' dfmat1 <- data_corpus_inaugural |>
#' corpus_subset(President == "Obama") |>
#' tokens(remove_punct = TRUE) |>
#' tokens_remove(stopwords("en")) |>
#' dfm() |>
#' dfm_trim(min_termfreq = 3)
#'
#' # basic wordcloud
Expand All @@ -77,23 +77,23 @@
#' color = col, rotation = FALSE)
#'
#' # comparison plot of Obama v. Trump
#' dfmat2 <- data_corpus_inaugural %>%
#' corpus_subset(President %in% c("Obama", "Trump")) %>%
#' tokens(remove_punct = TRUE) %>%
#' tokens_remove(stopwords("en")) %>%
#' dfmat2 <- data_corpus_inaugural |>
#' corpus_subset(President %in% c("Obama", "Trump")) |>
#' tokens(remove_punct = TRUE) |>
#' tokens_remove(stopwords("en")) |>
#' dfm()
#' dfmat2 <- dfm_group(dfmat2, dfmat2$President) %>%
#' dfmat2 <- dfm_group(dfmat2, dfmat2$President) |>
#' dfm_trim(min_termfreq = 3)
#'
#' textplot_wordcloud(dfmat2, comparison = TRUE, max_words = 100,
#' color = c("blue", "red"))
#'
#' \dontrun{
#' # for keyness
#' tstat <- data_corpus_inaugural[c(1, 3)] %>%
#' tokens(remove_punct = TRUE) %>%
#' tokens_remove(stopwords("en")) %>%
#' dfm() %>%
#' tstat <- data_corpus_inaugural[c(1, 3)] |>
#' tokens(remove_punct = TRUE) |>
#' tokens_remove(stopwords("en")) |>
#' dfm() |>
#' quanteda.textstats::textstat_keyness()
#' textplot_wordcloud(tstat, min_count = 2)
#' textplot_wordcloud(tstat, min_count = 2, comparison = FALSE)
Expand Down Expand Up @@ -367,9 +367,7 @@ wordcloud <- function(x, min_size, max_size, min_count, max_words,
#' @param min.freq deprecated argument
#' @param max.words deprecated argument
#' @param random.order deprecated argument
#' @param random.color deprecated argument
#' @param rot.per deprecated argument
#' @param ordered.colors deprecated argument
#' @param use.r.layout deprecated argument
#' @param title.size deprecated argument
#' @importFrom quanteda dfm_trim dfm_weight
Expand Down
22 changes: 12 additions & 10 deletions R/textplot_xray.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,28 @@
#' `textplot_xray`.
#' @examples
#' library("quanteda")
#' corp <- corpus_subset(data_corpus_inaugural, Year > 1970)
#' toks <- data_corpus_inaugural |>
#' corpus_subset(Year > 1970) |>
#' tokens()
#' # compare multiple documents
#' textplot_xray(kwic(corp, pattern = "american"))
#' textplot_xray(kwic(corp, pattern = "american"), scale = "absolute")
#' textplot_xray(kwic(toks, pattern = "american"))
#' textplot_xray(kwic(toks, pattern = "american"), scale = "absolute")
#'
#' # compare multiple terms across multiple documents
#' textplot_xray(kwic(corp, pattern = "america*"),
#' kwic(corp, pattern = "people"))
#' textplot_xray(kwic(toks, pattern = "america*"),
#' kwic(toks, pattern = "people"))
#'
#' \dontrun{
#' # how to modify the ggplot with different options
#' library("ggplot2")
#' tplot <- textplot_xray(kwic(corp, pattern = "american"),
#' kwic(corp, pattern = "people"))
#' tplot <- textplot_xray(kwic(toks, pattern = "american"),
#' kwic(toks, pattern = "people"))
#' tplot + aes(color = keyword) + scale_color_manual(values = c('red', 'blue'))
#'
#' # adjust the names of the document names
#' docnames(corp) <- apply(docvars(corp, c("Year", "President")), 1, paste, collapse = ", ")
#' textplot_xray(kwic(corp, pattern = "america*"),
#' kwic(corp, pattern = "people"))
#' docnames(toks) <- apply(docvars(toks, c("Year", "President")), 1, paste, collapse = ", ")
#' textplot_xray(kwic(toks, pattern = "america*"),
#' kwic(toks, pattern = "people"))
#' }
#' @export
#' @keywords textplot
Expand Down
4 changes: 2 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Submission notes

Resubmitting to reset the flag for the noSuggests, because a package that **quanteda.textplots** suggests was off CRAN for a week.
Fixes NOTEs warned about by CRAN on 22-Jan-2024.

# Checks

## Test environments

* local macOS 13.2.1, R 4.2.3
* local macOS 14.2.1, R 4.2.3
* Ubuntu 22.04 LTS, R 4.2.3
* Windows release via devtools::check_win_release()
* Windows devel via devtools::check_win_devel()
Expand Down
16 changes: 8 additions & 8 deletions man/textplot_keyness.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions man/textplot_network.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions man/textplot_wordcloud.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions man/textplot_xray.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions man/wordcloud_comparison.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/testthat/test-textplot_keyness.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ pdf(file = tempfile(".pdf"), width = 10, height = 10)

test_that("test textplot_keyness: show_reference works correctly ", {
skip("until quanteda.textstats is updated")
presdfm <- corpus_subset(data_corpus_inaugural, President %in% c("Obama", "Trump")) %>%
tokens(remove_punct = TRUE) %>%
tokens_remove(stopwords("en")) %>%
presdfm <- corpus_subset(data_corpus_inaugural, President %in% c("Obama", "Trump")) |>
tokens(remove_punct = TRUE) |>
tokens_remove(stopwords("en")) |>
dfm()
presdfm <- dfm_group(presdfm, groups = presdfm$President)
result <- quanteda.textstats::textstat_keyness(presdfm, target = "Trump")
Expand Down
Loading
Loading