Skip to content

Commit b04da2c

Browse files
authored
Merge pull request #24 from quanteda/dev-0.94.4
Fix CRAN issues
2 parents 3f0b802 + a083500 commit b04da2c

13 files changed

+106
-102
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: quanteda.textplots
22
Title: Plots for the Quantitative Analysis of Textual Data
3-
Version: 0.94.3
3+
Version: 0.94.4
44
Authors@R:
55
c(
66
person("Kenneth", "Benoit", email = "kbenoit@lse.ac.uk", role = c("cre", "aut", "cph"), comment = c(ORCID = "0000-0002-0797-564X")),
@@ -44,4 +44,4 @@ Encoding: UTF-8
4444
BugReports: https://github.com/quanteda/quanteda.textplots/issues
4545
Language: en-GB
4646
Roxygen: list(markdown = TRUE)
47-
RoxygenNote: 7.2.3
47+
RoxygenNote: 7.3.1

R/textplot_keyness.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
#' \dontrun{
2828
#' library("quanteda")
2929
#' # compare Trump speeches to other Presidents by chi^2
30-
#' dfmat1 <- data_corpus_inaugural %>%
31-
#' corpus_subset(Year > 1980) %>%
32-
#' tokens(remove_punct = TRUE) %>%
33-
#' tokens_remove(stopwords("en")) %>%
30+
#' dfmat1 <- data_corpus_inaugural |>
31+
#' corpus_subset(Year > 1980) |>
32+
#' tokens(remove_punct = TRUE) |>
33+
#' tokens_remove(stopwords("en")) |>
3434
#' dfm()
3535
#' dfmat1 <- dfm_group(dfmat1, groups = dfmat1$President)
3636
#' tstat1 <- quanteda.textstats::textstat_keyness(dfmat1, target = "Trump")
@@ -39,13 +39,13 @@
3939
#' textplot_keyness(tstat1, margin = 0.2, n = 10)
4040
#'
4141
#' # compare contemporary Democrats v. Republicans
42-
#' corp <- data_corpus_inaugural %>%
42+
#' corp <- data_corpus_inaugural |>
4343
#' corpus_subset(Year > 1960)
4444
#' corp$party <- ifelse(docvars(corp, "President") %in% c("Nixon", "Reagan", "Bush", "Trump"),
4545
#' "Republican", "Democrat")
46-
#' dfmat2 <- corp %>%
47-
#' tokens(remove_punct = TRUE) %>%
48-
#' tokens_remove(stopwords("en")) %>%
46+
#' dfmat2 <- corp |>
47+
#' tokens(remove_punct = TRUE) |>
48+
#' tokens_remove(stopwords("en")) |>
4949
#' dfm()
5050
#' tstat2 <- quanteda.textstats::textstat_keyness(dfm_group(dfmat2, groups = dfmat2$party),
5151
#' target = "Democrat", measure = "lr")

R/textplot_network.R

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,22 @@
3434
#' @examples
3535
#' set.seed(100)
3636
#' library("quanteda")
37-
#' toks <- data_char_ukimmig2010 %>%
38-
#' tokens(remove_punct = TRUE) %>%
39-
#' tokens_tolower() %>%
37+
#' toks <- data_char_ukimmig2010 |>
38+
#' tokens(remove_punct = TRUE) |>
39+
#' tokens_tolower() |>
4040
#' tokens_remove(pattern = stopwords("english"), padding = FALSE)
4141
#' fcmat <- fcm(toks, context = "window", tri = FALSE)
42-
#' feat <- names(topfeatures(fcmat, 30))
43-
#' fcm_select(fcmat, pattern = feat) %>%
42+
#' feat <- colSums(fcmat) |>
43+
#' sort(decreasing = TRUE) |>
44+
#' head(30) |>
45+
#' names()
46+
#' fcm_select(fcmat, pattern = feat) |>
4447
#' textplot_network(min_freq = 0.5)
45-
#' fcm_select(fcmat, pattern = feat) %>%
48+
#' fcm_select(fcmat, pattern = feat) |>
4649
#' textplot_network(min_freq = 0.8)
47-
#' fcm_select(fcmat, pattern = feat) %>%
50+
#' fcm_select(fcmat, pattern = feat) |>
4851
#' textplot_network(min_freq = 0.8, vertex_labelcolor = rep(c('gray40', NA), 15))
49-
#' fcm_select(fcmat, pattern = feat) %>%
52+
#' fcm_select(fcmat, pattern = feat) |>
5053
#' textplot_network(vertex_labelsize = 10)
5154
#' fcm_30 <- fcm_select(fcmat, pattern = feat)
5255
#' textplot_network(fcm_30,
@@ -198,7 +201,7 @@ as.igraph <- function(x, ...) UseMethod("as.igraph")
198201
#' # as.igraph
199202
#' if (requireNamespace("igraph", quietly = TRUE)) {
200203
#' txt <- c("a a a b b c", "a a c e", "a c e f g")
201-
#' mat <- fcm(txt)
204+
#' mat <- fcm(tokens(txt))
202205
#' as.igraph(mat, min_freq = 1, omit_isolated = FALSE)
203206
#' }
204207
as.igraph.fcm <- function(x, min_freq = 0.5, omit_isolated = TRUE, ...) {

R/textplot_wordcloud.R

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@
5757
#' # plot the features (without stopwords) from Obama's inaugural addresses
5858
#' set.seed(10)
5959
#' library("quanteda")
60-
#' dfmat1 <- data_corpus_inaugural %>%
61-
#' corpus_subset(President == "Obama") %>%
62-
#' tokens(remove_punct = TRUE) %>%
63-
#' tokens_remove(stopwords("en")) %>%
64-
#' dfm() %>%
60+
#' dfmat1 <- data_corpus_inaugural |>
61+
#' corpus_subset(President == "Obama") |>
62+
#' tokens(remove_punct = TRUE) |>
63+
#' tokens_remove(stopwords("en")) |>
64+
#' dfm() |>
6565
#' dfm_trim(min_termfreq = 3)
6666
#'
6767
#' # basic wordcloud
@@ -77,23 +77,23 @@
7777
#' color = col, rotation = FALSE)
7878
#'
7979
#' # comparison plot of Obama v. Trump
80-
#' dfmat2 <- data_corpus_inaugural %>%
81-
#' corpus_subset(President %in% c("Obama", "Trump")) %>%
82-
#' tokens(remove_punct = TRUE) %>%
83-
#' tokens_remove(stopwords("en")) %>%
80+
#' dfmat2 <- data_corpus_inaugural |>
81+
#' corpus_subset(President %in% c("Obama", "Trump")) |>
82+
#' tokens(remove_punct = TRUE) |>
83+
#' tokens_remove(stopwords("en")) |>
8484
#' dfm()
85-
#' dfmat2 <- dfm_group(dfmat2, dfmat2$President) %>%
85+
#' dfmat2 <- dfm_group(dfmat2, dfmat2$President) |>
8686
#' dfm_trim(min_termfreq = 3)
8787
#'
8888
#' textplot_wordcloud(dfmat2, comparison = TRUE, max_words = 100,
8989
#' color = c("blue", "red"))
9090
#'
9191
#' \dontrun{
9292
#' # for keyness
93-
#' tstat <- data_corpus_inaugural[c(1, 3)] %>%
94-
#' tokens(remove_punct = TRUE) %>%
95-
#' tokens_remove(stopwords("en")) %>%
96-
#' dfm() %>%
93+
#' tstat <- data_corpus_inaugural[c(1, 3)] |>
94+
#' tokens(remove_punct = TRUE) |>
95+
#' tokens_remove(stopwords("en")) |>
96+
#' dfm() |>
9797
#' quanteda.textstats::textstat_keyness()
9898
#' textplot_wordcloud(tstat, min_count = 2)
9999
#' textplot_wordcloud(tstat, min_count = 2, comparison = FALSE)
@@ -367,9 +367,7 @@ wordcloud <- function(x, min_size, max_size, min_count, max_words,
367367
#' @param min.freq deprecated argument
368368
#' @param max.words deprecated argument
369369
#' @param random.order deprecated argument
370-
#' @param random.color deprecated argument
371370
#' @param rot.per deprecated argument
372-
#' @param ordered.colors deprecated argument
373371
#' @param use.r.layout deprecated argument
374372
#' @param title.size deprecated argument
375373
#' @importFrom quanteda dfm_trim dfm_weight

R/textplot_xray.R

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,28 @@
2424
#' `textplot_xray`.
2525
#' @examples
2626
#' library("quanteda")
27-
#' corp <- corpus_subset(data_corpus_inaugural, Year > 1970)
27+
#' toks <- data_corpus_inaugural |>
28+
#' corpus_subset(Year > 1970) |>
29+
#' tokens()
2830
#' # compare multiple documents
29-
#' textplot_xray(kwic(corp, pattern = "american"))
30-
#' textplot_xray(kwic(corp, pattern = "american"), scale = "absolute")
31+
#' textplot_xray(kwic(toks, pattern = "american"))
32+
#' textplot_xray(kwic(toks, pattern = "american"), scale = "absolute")
3133
#'
3234
#' # compare multiple terms across multiple documents
33-
#' textplot_xray(kwic(corp, pattern = "america*"),
34-
#' kwic(corp, pattern = "people"))
35+
#' textplot_xray(kwic(toks, pattern = "america*"),
36+
#' kwic(toks, pattern = "people"))
3537
#'
3638
#' \dontrun{
3739
#' # how to modify the ggplot with different options
3840
#' library("ggplot2")
39-
#' tplot <- textplot_xray(kwic(corp, pattern = "american"),
40-
#' kwic(corp, pattern = "people"))
41+
#' tplot <- textplot_xray(kwic(toks, pattern = "american"),
42+
#' kwic(toks, pattern = "people"))
4143
#' tplot + aes(color = keyword) + scale_color_manual(values = c('red', 'blue'))
4244
#'
4345
#' # adjust the names of the document names
44-
#' docnames(corp) <- apply(docvars(corp, c("Year", "President")), 1, paste, collapse = ", ")
45-
#' textplot_xray(kwic(corp, pattern = "america*"),
46-
#' kwic(corp, pattern = "people"))
46+
#' docnames(toks) <- apply(docvars(toks, c("Year", "President")), 1, paste, collapse = ", ")
47+
#' textplot_xray(kwic(toks, pattern = "america*"),
48+
#' kwic(toks, pattern = "people"))
4749
#' }
4850
#' @export
4951
#' @keywords textplot

cran-comments.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Submission notes
22

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

55
# Checks
66

77
## Test environments
88

9-
* local macOS 13.2.1, R 4.2.3
9+
* local macOS 14.2.1, R 4.2.3
1010
* Ubuntu 22.04 LTS, R 4.2.3
1111
* Windows release via devtools::check_win_release()
1212
* Windows devel via devtools::check_win_devel()

man/textplot_keyness.Rd

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/textplot_network.Rd

Lines changed: 12 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/textplot_wordcloud.Rd

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/textplot_xray.Rd

Lines changed: 12 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/wordcloud_comparison.Rd

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-textplot_keyness.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ pdf(file = tempfile(".pdf"), width = 10, height = 10)
44

55
test_that("test textplot_keyness: show_reference works correctly ", {
66
skip("until quanteda.textstats is updated")
7-
presdfm <- corpus_subset(data_corpus_inaugural, President %in% c("Obama", "Trump")) %>%
8-
tokens(remove_punct = TRUE) %>%
9-
tokens_remove(stopwords("en")) %>%
7+
presdfm <- corpus_subset(data_corpus_inaugural, President %in% c("Obama", "Trump")) |>
8+
tokens(remove_punct = TRUE) |>
9+
tokens_remove(stopwords("en")) |>
1010
dfm()
1111
presdfm <- dfm_group(presdfm, groups = presdfm$President)
1212
result <- quanteda.textstats::textstat_keyness(presdfm, target = "Trump")

0 commit comments

Comments
 (0)