From 5c1a25573e07e3c2740ef46410c28f730f44d92b Mon Sep 17 00:00:00 2001 From: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com> Date: Sat, 18 May 2024 21:18:50 +0100 Subject: [PATCH] lintr --- R/text_format.R | 6 +++--- tests/testthat/test-standardize_datagrid.R | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/text_format.R b/R/text_format.R index 180807746..b15935542 100644 --- a/R/text_format.R +++ b/R/text_format.R @@ -78,8 +78,8 @@ text_concatenate <- function(text, sep = ", ", last = " and ", enclose = NULL) { if (length(text) == 1) { s <- text } else { - s <- paste0(text[1:(length(text) - 1)], collapse = sep) - s <- paste0(c(s, text[length(text)]), collapse = last) + s <- paste(text[1:(length(text) - 1)], collapse = sep) + s <- paste(c(s, text[length(text)]), collapse = last) } s } @@ -130,7 +130,7 @@ text_wrap <- function(text, width = NULL, ...) { if (nchar(s) > width) { leading_spaces <- nchar(s) - nchar(insight::trim_ws(s)) s <- strwrap(s, width = width) - s <- paste0(s, collapse = "\n") + s <- paste(s, collapse = "\n") s <- paste0(strrep(" ", leading_spaces), s) } wrapped <- paste0(wrapped, s, "\n") diff --git a/tests/testthat/test-standardize_datagrid.R b/tests/testthat/test-standardize_datagrid.R index c32616bdc..2c095e6bc 100644 --- a/tests/testthat/test-standardize_datagrid.R +++ b/tests/testthat/test-standardize_datagrid.R @@ -2,10 +2,10 @@ test_that("standardize.datagrid", { x <- insight::get_datagrid(iris, by = "Sepal.Length", range = "sd", length = 3) out <- standardize(x) - expect_equal(as.numeric(out$Sepal.Length), c(-1, 0, 1)) - expect_equal(as.numeric(out$Sepal.Width), c(0, 0, 0)) + expect_identical(as.numeric(out$Sepal.Length), c(-1, 0, 1), tolerance = 1e-3) + expect_identical(as.numeric(out$Sepal.Width), c(0, 0, 0), tolerance = 1e-3) x <- insight::get_datagrid(iris, by = "Sepal.Length = c(-1, 0)") out <- unstandardize(x, select = "Sepal.Length") - expect_equal(out$Sepal.Length[1:2], c(mean(iris$Sepal.Length) - sd(iris$Sepal.Length), mean(iris$Sepal.Length))) + expect_identical(out$Sepal.Length[1:2], c(mean(iris$Sepal.Length) - sd(iris$Sepal.Length), mean(iris$Sepal.Length)), tolerance = 1e-3) })