gadenbuie / xaringanExtra

:ferris_wheel: A playground of enhancements and extensions for xaringan slides.
https://pkg.garrickadenbuie.com/xaringanExtra
Other
448 stars 36 forks source link

In xaringan slides, panelset breaks on using the glimpse function #151

Closed koliajaykr closed 2 years ago

koliajaykr commented 2 years ago
---
title: "Dynamic Documents"
subtitle: "Online Training Program"
author: "By: Ajay Koli"
date: "`r format(Sys.Date(), '%B %e, %Y')`"
output:
  xaringan::moon_reader:
    includes:
      after_body: insert-logo.html
    css: ["default", "css/my-theme.css", "css/my-fonts.css"]
    seal: false
    lib_dir: libs
    nature:
      # autoplay: 5000
      highlightStyle: solarized-light
      highlightLanguage: ["r", "css", "yaml"]
      slideNumberFormat: "%current%/%total%" 
      highlightLines: true
      countIncrementalSlides: false
      ratio: "16:9"
---

```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
knitr::opts_chunk$set(collapse = TRUE,
                      fig.retina = 3,
                      echo = FALSE,
                      fig.align='center')
library(tidyverse)
library(xaringanExtra)
library(palmerpenguins)
xaringanExtra::use_tachyons()
xaringanExtra::use_tile_view()
xaringanExtra::use_fit_screen()
xaringanExtra::use_extra_styles(hover_code_line = TRUE, mute_unhighlighted_code = TRUE)
xaringanExtra::use_share_again()
xaringanExtra::use_panelset()

class: hide-logo

A Glimpse of Data

.panelset[

.panel[.panel-name[Codes]

glimpse(penguins) #<<

]

.panel[.panel-name[Output]

] ]


<img width="595" alt="Screenshot 2022-01-20 at 12 39 09 AM" src="https://user-images.githubusercontent.com/28312545/150197973-6bb0d85b-dfe6-4290-b722-029321ee8b98.png">

The whole thing works fine if I use `summary()` instead of `glimpse()`.

<img width="577" alt="Screenshot 2022-01-20 at 12 41 53 AM" src="https://user-images.githubusercontent.com/28312545/150198365-94c224c8-7fa1-4be6-bd15-64ddb6231486.png">

The Session info is

R version 4.0.2 (2020-06-22) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: OS X 12.1

Matrix products: default LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods
[7] base

other attached packages: [1] icon_0.1.0 metathis_1.1.1
[3] palmerpenguins_0.1.0 emoji_0.2.0
[5] xaringanExtra_0.2.3.9000 icons_0.2.0
[7] ggthemes_4.2.4 forcats_0.5.1
[9] stringr_1.4.0 dplyr_1.0.7
[11] purrr_0.3.4 readr_2.1.1
[13] tidyr_1.1.4 tibble_3.1.6
[15] ggplot2_3.3.5 tidyverse_1.3.1
[17] ymlthis_0.1.5 countdown_0.3.5

loaded via a namespace (and not attached): [1] fs_1.5.2 lubridate_1.8.0 bit64_4.0.5
[4] httr_1.4.2 tools_4.0.2 backports_1.4.1
[7] bslib_0.3.1 utf8_1.2.2 R6_2.5.1
[10] DBI_1.1.2 colorspace_2.0-2 withr_2.4.3
[13] processx_3.5.2 tidyselect_1.1.1 bit_4.0.4
[16] compiler_4.0.2 cli_3.1.0 rvest_1.0.2
[19] xml2_1.3.3 sass_0.4.0 scales_1.1.1
[22] callr_3.7.0 rappdirs_0.3.3 digest_0.6.29
[25] rmarkdown_2.11 pkgconfig_2.0.3 htmltools_0.5.2
[28] sessioninfo_1.2.2 dbplyr_2.1.1 fastmap_1.1.0
[31] highr_0.9 rlang_0.4.12 readxl_1.3.1
[34] rstudioapi_0.13 xaringan_0.22 jquerylib_0.1.4
[37] generics_0.1.1 jsonlite_1.7.3 vroom_1.5.7
[40] magrittr_2.0.1 Rcpp_1.0.8 munsell_0.5.0
[43] fansi_1.0.2 lifecycle_1.0.1 whisker_0.4
[46] stringi_1.7.6 yaml_2.2.1 grid_4.0.2
[49] parallel_4.0.2 promises_1.2.0.1 crayon_1.4.2
[52] haven_2.4.3 hms_1.1.1 ps_1.6.0
[55] knitr_1.37 pillar_1.6.4 emo_0.0.0.9000
[58] reprex_2.0.1 servr_0.24 glue_1.6.0
[61] evaluate_0.14 modelr_0.1.8 vctrs_0.3.8
[64] png_0.1-7 tzdb_0.2.0 httpuv_1.6.5
[67] cellranger_1.1.0 gtable_0.3.0 assertthat_0.2.1 [70] xfun_0.29 mime_0.12 broom_0.7.11
[73] later_1.3.0 rsconnect_0.8.25 ellipsis_0.3.2

gadenbuie commented 2 years ago

@koliajaykr This example is part of a larger slide deck, correct? Do you also see the issue for this smaller reprex document? I'm not able to reproduce the issue and as far as I can tell we have the same package versions

gadenbuie commented 2 years ago

I can get the error to reproduce if I add the following to the setup chunk.

Sys.setenv(R_CLI_NUM_COLORS = 256)

Can you please restart your R session and check if this value is somehow set in your environment by calling

Sys.getenv("R_CLI_NUM_COLORS")

Alternatively, you'll probably be able to suppress the terminal color codes by setting that value to 1 in the setup chunk.

Sys.setenv(R_CLI_NUM_COLORS = 1)
cderv commented 2 years ago

ANSI coloring should be deactivated by default in rmarkdown document unless it is activated somewhere by an option or an environment variable. (like it was some time ago in GHA workflow for example)

Can you also check getOption("crayon.enabled") in your R session ?

However, cli.num_colors options and R_CLI_NUM_COLORS env var are checked before the above. So if it is set, it would activate.

Can you try the generic crayon::has_color() in a chunk your xaringan slide ? It should be FALSE, but I believe it will be true for your somehow. Debugging this function step by step could help us determine which option is set to opt-in coloring.

koliajaykr commented 2 years ago

Thank you for extending your help.

This issue is resolved. It seems to restart the computer and RStudio worked somehow.

cderv commented 2 years ago

Glad it is working now. It must have been one of these options / env var set that caused the trouble.

koliajaykr commented 2 years ago

Glad it is working now. It must have been one of these options / env var set that caused the trouble.

Frankly, speaking I did not add or remove any options. Just re-starting the computer and RStudio solved this issue.