Closed brianmsm closed 2 years ago
Can you try a couple things for me?
eval = FALSE
?[
or ]
characters, in the first 10 rows?If I remove the text before the first chunk, it still doesn't work
It works if I set eval = FALSE in the code that's going to print the output
In same way if I only save output in another object such as df
.sav
) that contains labels associated to its variables and labels of values in different variables. Printing tibbles has this visualization:
It could be likely that when representing value labels with square brackets, they interfere with panelset. In fact, I only need to put the output of the first data import for panelset to break:
---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
institute: "RStudio, PBC"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
xaringan::moon_reader:
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
library(xaringanExtra)
library(tidyverse)
xaringanExtra::use_panelset()
.panelset[ .panel[.panel-name[R Code]
haven::read_sav("https://raw.githubusercontent.com/healthinnovation/curso-introduccion-r-tidyverse/main/sesion_04/data/RECH1.sav")
]
.panel[.panel-name[Another] More text ] ]
![image](https://user-images.githubusercontent.com/28207224/172028487-16da55a3-16d9-44f7-90e3-7908487f5c7c.png)
I've been exploring a bit more... and it's kind of strange. It seems to be related to the use of labels, but also about the number of columns to print on the screen.
If I restrict with the select function to have only a few columns (no matter what they are) so that the printing will fit on the screen, panelset works without problems.
If I add one more column in the select, panelset breaks again.
But, if this additional column is a variable with no associated variable label, panelset doesn't break no matter how much the screen printing is overflowed.
I recreated an artificial data by adding data labels with the labelled package, and the problem was reproduced in the same way.
---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
institute: "RStudio, PBC"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
xaringan::moon_reader:
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
library(xaringanExtra)
library(tidyverse)
xaringanExtra::use_panelset()
.panelset[ .panel[.panel-name[R Code]
library(labelled)
df <- tibble(s1 = c("M", "M", "F"),
s2 = c(1, 1, 2),
s3 = c("P", "B", "B"),
s4 = c("M", "M", "F"),
s5 = c(1, 1, 2),
s6 = c("P", "B", "B"),
s7 = c("M", "M", "F"),
s8 = c(1, 1, 2),
s9 = c("P", "B", "B")) %>%
set_variable_labels(s1 = "Sex", s2 = "Question") %>%
set_value_labels(s1 = c(Male = "M", Female = "F"),
s2 = c(Yes = 1, No = 2),
s3 = c(Brother = "B", Parents = "P"),
s4 = c(Male = "M", Female = "F"),
s5 = c(Yes = 1, No = 2),
s6 = c(Brother = "B", Parents = "P"),
s7 = c(Male = "M", Female = "F"),
s8 = c(Yes = 1, No = 2),
s9 = c(Brother = "B", Parents = "P"))
df %>%
select(s1:s8)
]
.panel[.panel-name[Another] More text ] ]
![image](https://user-images.githubusercontent.com/28207224/172028974-840693ef-e19a-4b10-8ed4-cc61343c8c43.png)
Thanks for doing all that exploration! I think it comes down to needing the square brackets to be balanced. In other words it seems [labelled]
is okay but [labelled...
is not.
This points to issues with the markdown parser used by remarkjs (the slides library used by xaringan), which unfortunately means it's not something I can fix. You'll have to work around it by adjusting the rows or number of columns shown in the preview.
I'm not sure what the problem is... as I've been using panelset with no problems so far. I'm going round and round and can't find the error or the solution.
Panelset just doesn't work in this case.
Title
.panelset[ .panel[.panel-name[R Code]
There is text here.
]
.panel[.panel-name[Another] More text ] ]