From be2fd266a414086d5f39e5f51394cc4ea5f4cca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Catalina=20Ca=C3=B1izares?= <88352293+ccani007@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:06:50 -0700 Subject: [PATCH] Eliminate `stringsAsFactors` (#2755) Fixes #2708 --- R/build-news.R | 3 +-- R/utils.R | 3 +-- tests/testthat/test-build-news.R | 7 +++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/R/build-news.R b/R/build-news.R index 481b64d44..dff8a2300 100644 --- a/R/build-news.R +++ b/R/build-news.R @@ -192,7 +192,7 @@ data_news <- function(pkg, call = caller_env() ) { } else { timeline <- NULL } - + purrr::walk2( sections, versions, @@ -284,7 +284,6 @@ pkg_timeline <- function(package) { data.frame( version = names(timeline), date = as.Date(timeline), - stringsAsFactors = FALSE, row.names = NULL ) } diff --git a/R/utils.R b/R/utils.R index 7f84d5e5c..abd609dd3 100644 --- a/R/utils.R +++ b/R/utils.R @@ -109,7 +109,6 @@ re_match <- function(text, pattern, perl = TRUE, ...) { matchstr[ start == -1 ] <- NA_character_ res <- data.frame( - stringsAsFactors = FALSE, .text = text, .match = matchstr ) @@ -124,7 +123,7 @@ re_match <- function(text, pattern, perl = TRUE, ...) { groupstr[ gstart == -1 ] <- NA_character_ dim(groupstr) <- dim(gstart) - res <- cbind(groupstr, res, stringsAsFactors = FALSE) + res <- cbind(groupstr, res) } names(res) <- c(attr(match, "capture.names"), ".text", ".match") diff --git a/tests/testthat/test-build-news.R b/tests/testthat/test-build-news.R index 6bae9fb5d..ba548b5ab 100644 --- a/tests/testthat/test-build-news.R +++ b/tests/testthat/test-build-news.R @@ -23,8 +23,8 @@ test_that("news is syntax highlighted once", { pkg <- local_pkgdown_site() pkg <- pkg_add_file(pkg, "NEWS.md", c( "# testpackage 1.0.0.9000", - "```r", - "x <- 1", + "```r", + "x <- 1", "```" )) suppressMessages(build_news(pkg, preview = FALSE)) @@ -117,8 +117,7 @@ test_that("correct timeline for first ggplot2 releases", { timeline <- pkg_timeline("ggplot2")[1:3, ] expected <- data.frame( version = c("0.5", "0.5.1", "0.5.2"), - date = as.Date(c("2007-06-01", "2007-06-09", "2007-06-18")), - stringsAsFactors = FALSE + date = as.Date(c("2007-06-01", "2007-06-09", "2007-06-18")) ) expect_equal(timeline, expected)