-
-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slide break not recognised when rendered with the Knit button #332
Comments
That sounds like a really weird bug. @cderv Could you take a look? Thanks! |
Wow, this is indeed a weird bug!
This only happens in RStudio IDE so I believe it has something to do with what the IDE is doing with paged table. I believe some hooks are used inside the IDE directly to replace R functions. This could lead to differences in behavior between Knitting in the IDE and Knitting at command line. Thanks for the great report @charliejhadley !! It helps. We'll need to investigate more now - and yes this is an issue with RStudio IDE not xaringan I believe. |
To investigate further, I compared the different output and found a difference. How rendering works with paged table ?Small reminder on how this works:
Differences between IDE rendering and Console renderingRegarding the differences between IDE rendered and Console rendered
I can confirm that slicing the data.frame before printing will solve this. ---
title: "Works regardless"
output:
xaringan::moon_reader:
df_print: paged
---
## Slide with paged df
```{r}
utils::head(maps::world.cities, 1000)
```
---
## Slide with code
Eg `foobar` One thing to note here is that, nrow(maps::world.cities)
#> [1] 43645 Usually, it is not a good idea to print the whole data.frame in an HTML document - it could cause performance issues. It is why by default, Obviously, using it directly solves also the issue as this works. ---
title: "Works in moonreader, but not knitted"
output:
xaringan::moon_reader:
df_print: paged
---
## Slide with paged df
```{r, max.print = 1500}
maps::world.cities
```
---
## Slide with code
Eg `foobar` Regarding
|
Just to confirm my hunch I looked at this hypothesis, and I believe this is what is causing the issue: The The city is question is If we try to remove it, we have 3 slides as expected ---
title: "Works regardless"
output:
xaringan::moon_reader:
df_print: paged
---
## Slide with paged df
```{r}
maps::world.cities[-3238,]
```
---
## Slide with code
Eg `foobar` @charliejhadley I believe this is an issue of character escaping, as xaringan uses remark.js which will parse the content of the body as Markdown. Can you confirm this works for you? |
Ahh, great to see you've discovered what was causing this @cderv! Yup, knocking out row 3238 makes the Knit button behave the same as You've probably already realised there's a more minimal reprex now, but just in case here you go:
|
yes thanks for sharing this ! I knew I have encountered this before and I think this issue is in a way a duplicate of #272 Same type of issue with the parser |
Ooops @cderv I made a mistake! That's not actually a reprex for the issue I first reported because that .Rmd behaved identically for the Knit button and This is a slightly simpler, true reprex of my initial issue, and it demonstrates there is something very specific about the order of the vector
|
I believe the differences comes from the There are two issues:
No backticks - Works in both Button and Console---
title: "Knit button misbehaves"
output:
xaringan::moon_reader:
df_print: paged
---
## Slide with paged df
```{r}
cities <- maps::world.cities$name
positions_of_backticks <- which(grepl("`", cities))
maps::world.cities[-positions_of_backticks, ]
```
---
## Slide with code
Eg `foobar` backtick name at the 1001st row - Do not work with Button but works in Console---
title: "Knit button misbehaves"
output:
xaringan::moon_reader:
df_print: paged
---
## Slide with paged df
```{r}
cities <- maps::world.cities$name
positions_of_backticks <- which(grepl("`", cities))
df <- maps::world.cities[-positions_of_backticks, ]
df[1001, ] <- maps::world.cities[positions_of_backticks[1], ]
df
```
---
## Slide with code
Eg `foobar` Backtick name at the 999th row - Does not work in both Button and Console---
title: "Knit button misbehaves"
output:
xaringan::moon_reader:
df_print: paged
---
## Slide with paged df
```{r}
cities <- maps::world.cities$name
positions_of_backticks <- which(grepl("`", cities))
df <- maps::world.cities[-positions_of_backticks, ]
df[999, ] <- maps::world.cities[positions_of_backticks[1], ]
df
```
---
## Slide with code
Eg `foobar`
Is there more than that for you ? |
This is a weird bug, it occurs only in {xaringan} slides when RStudio's "Knit" button is used. Please follow these steps for a reprex:
.Rmd
file and save it into an RStudio project.xaringan:::inf_mr()
It appears the following circumstances lead to this bug:
df_print
is set topaged
data.frame
The bug does not occur if slides after the slide with a printed
data.frame
do not contain code, eg this .Rmd file is unaffected:While there is already a fix - using
rmarkdown::render()
- I would argue that most RMarkdown user's either click this button or use the Cmd+Shift+K keyboard shortcut which does the same thing.I also acknowledge that this bug might be better placed against the RStudio IDE instead of {xaringan}, I'm happy to re-report this elsewhere if you would prefer.
xfun::session_info('xaringan')
By filing an issue to this repo, I promise that
xfun::session_info('xaringan')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/xaringan')
.I understand that my issue may be closed if I don't fulfill my promises.
The text was updated successfully, but these errors were encountered: