Replies: 3 comments 5 replies
-
x <- "easystats is a collection of R packages, which aims to provide a unifying and consistent framework to tame, discipline, and harness the scary R statistics and their pesky models."
(x_wrap <- strwrap(x, width = 80, exdent = 2))
#> [1] "easystats is a collection of R packages, which aims to provide a unifying and"
#> [2] " consistent framework to tame, discipline, and harness the scary R statistics"
#> [3] " and their pesky models."
cat(paste0(x_wrap, collapse = "\n"))
#> easystats is a collection of R packages, which aims to provide a unifying and
#> consistent framework to tame, discipline, and harness the scary R statistics
#> and their pesky models.
message(paste0(x_wrap, collapse = "\n"))
#> easystats is a collection of R packages, which aims to provide a unifying and
#> consistent framework to tame, discipline, and harness the scary R statistics
#> and their pesky models.
warning(paste0(x_wrap, collapse = "\n"), call. = FALSE)
#> Warning: easystats is a collection of R packages, which aims to provide a unifying and
#> consistent framework to tame, discipline, and harness the scary R statistics
#> and their pesky models.
stop(paste0(x_wrap, collapse = "\n"), call. = FALSE)
#> Error: easystats is a collection of R packages, which aims to provide a unifying and
#> consistent framework to tame, discipline, and harness the scary R statistics
#> and their pesky models.
x_wrap2 <- strwrap(x, width = 80, exdent = 2,
prefix = "EASYSTATS> ")
cat(paste0(x_wrap2, collapse = "\n"))
#> EASYSTATS> easystats is a collection of R packages, which aims to provide a
#> EASYSTATS> unifying and consistent framework to tame, discipline, and harness
#> EASYSTATS> the scary R statistics and their pesky models. Created on 2022-04-17 by the reprex package (v2.0.1) |
Beta Was this translation helpful? Give feedback.
0 replies
-
We could replace the internal x <- "easystats is a collection of R packages, which aims to provide a unifying and consistent framework to tame, discipline, and harness the scary R statistics and their pesky models."
microbenchmark::microbenchmark(
strwrap = paste(strwrap(x, exdent = 2, width = 70), collapse = "\n"),
wrap_msg = insight:::.wrap_message_line(x, line_length = 70),
times = 1000
)
#> Unit: microseconds
#> expr min lq mean median uq max neval cld
#> strwrap 215.501 240.651 327.5591 275.5010 373.451 5729.901 1000 a
#> wrap_msg 185.902 206.001 320.1423 225.0015 314.302 50151.301 1000 a Created on 2022-04-17 by the reprex package (v2.0.1) |
Beta Was this translation helpful? Give feedback.
0 replies
-
In which way? |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just realized that
strwrap()
exists. It's super useful for wrapping long text lines to the width of the console. It has similar functionality asinsight::format_message()
but better handles text that needs to break across more than 2 lines. Shouldn't need to updateinsight::format_message()
because we shouldn't write messages that are that long.cc @strengejacke
Beta Was this translation helpful? Give feedback.
All reactions