Reputation: 148
I face an encoding issue with the latest version of RStudio when I try to capture the output.
If I define a tibble and print it, I obtain the expected result:
library(dplyr)
x <- tibble(test=c("Hello","World"))
print(x)
(The result is)
# A tibble: 2 x 1
test
<chr>
1 Hello
2 World
But, within a shiny app, I need to capture the results as following:
txt <- capture.output(x, type = "output")
print(txt)
Here, I obtain:
[1] "\033[38;5;246m# A tibble: 2 x 1\033[39m" " tes "
[3] " \033[3m\033[38;5;246m<chr>\033[39m\033[23m" "\033[38;5;250m1\033[39m Hello"
[5] "\033[38;5;250m2\033[39m World"
I didn't get the issue with former versions of RStudio. I don't get it using R GUI.
RStudio version is:
$mode
[1] "desktop"
$version
[1] ‘1.4.1106’
$release_name
[1] "Tiger Daylily"
R Session info is:
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_1.0.5
loaded via a namespace (and not attached):
[1] fansi_0.4.2 assertthat_0.2.1 utf8_1.2.1 crayon_1.4.1 R6_2.5.0 DBI_1.1.1
[7] lifecycle_1.0.0 magrittr_2.0.1 pillar_1.6.0 cli_2.4.0 rlang_0.4.10 rstudioapi_0.13
[13] vctrs_0.3.7 generics_0.1.0 ellipsis_0.3.1 forcats_0.5.1 tools_4.0.5 glue_1.4.2
[19] purrr_0.3.4 compiler_4.0.5 pkgconfig_2.0.3 tidyselect_1.1.0 tibble_3.1.0
Upvotes: 1
Views: 97
Reputation: 84709
This is for colors and highlighting. You can disable with:
options(cli.num_colors=1)
Upvotes: 1