0

我在编译我的 { flipbookr} 套牌时遇到问题。我可以毫无问题地运行模板,但是我得到了一个空白文件,当我自己编织时它不会前进。

在此处输入图像描述

如果我删除对它的调用,chunk_reveal()它会起作用。

r chunk_reveal("cars", break_type = "auto")

据我所知,我与模板做的唯一不同的事情(除了缩短它)是在设置块中获取外部数据,然后在仍然命名为汽车的块中处理该数据。

仅供参考,我在包 github repo 上发布了一个问题,但我不清楚这样的问题是 SO 用户可以帮助我解决的编码问题还是开发人员应该看到的包问题。

这是一个基于应该重现问题的模板的示例。

---
title: "The art of flipbooking"
subtitle: "With flipbookr and xaringan"
author: "Gina Reynolds, December 2019"
output:
  xaringan::moon_reader:
    lib_dir: libs
    css: [default, hygge, ninjutsu]
    nature:
      ratio: 16:10
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
---

```{r setup, include = F}
# This is the recommended set up for flipbooks
# you might think about setting cache to TRUE as you gain practice --- building flipbooks from scracth can be time consuming
knitr::opts_chunk$set(fig.width = 6, message = FALSE, warning = FALSE, comment = "", cache = FALSE, fig.retina = 3)
library(flipbookr)
library(tidyverse)

covid <- read.csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv", 
                  stringsAsFactors = FALSE)
```



# Using `flipbookr::chunk_reveal()`

You will use the `chunk_reveal()` function [inline](https://rmarkdown.rstudio.com/lesson-4.html) to generate the derivitive code chunks, rather than inside of a code chunk, so that the text that is generated is interpreted correctly when rendered.  The inline code will look something like this:

<!-- The above is for the html output version, just look at the examples below if you are in the source! -->
```markdown
``r "r chunk_reveal(chunk_name = \"cars\", break_type = \"user\")"``
``` 

There are several modalities that you might be interested in using for "flipbookifying" your code and the next section is dedicated to demoing some of them below.

- **break type** -- *which lines of code should be revealed when*, `break_type` defaults to "auto"
- **display type** -- *display code and output, or just output, or just code?*, `display_type` defaults to "both"
- **assignment type** -- *does code chunk use left assignment?*, `left_assign` defaults to FALSE

---

At first we'll apply our flipbooking to the below input code - the code chunk is named "cars".  For now I set echo = TRUE for this code chunk, so you can see the code content but sometimes you might like to set echo to FALSE. This code uses tidyverse tools, so we loaded that too in the "setup" code chunk at the beginning of the template. 

```{r cars, include = FALSE}
covid %>%
  filter(state!="District of Columbia" &
           state!="Puerto Rico" &
           state!="Hawaii" &
           state!="Alaska") %>%
  select(date, fips, cases, deaths) %>%
  mutate(date = lubridate::ymd(date)) %>%
  mutate(fips = stringr::str_pad(fips, width=5, pad="0")) %>%
  mutate(month = lubridate::month(date, 
                                  label=TRUE, 
                                  abbr=TRUE),
         day = lubridate::day(date),
         monthDay = paste(month, day, sep=" ")) 
```

---

# `break_type`

Notice the regular comments and the special #BREAK comments, these will be used for a couple of the different "break type" modalities.


```{r, code = knitr::knit_code$get("cars"), eval = FALSE, echo = TRUE}
```

<!-- Also notice how we've created a new code chunk with the code from the previous chunk by calling knitr::knit_code$get("cars"). -->
<!-- This slide is also about giving you some intuition about how flipbooking works in the background. -->
<!-- (more on this [here](https://emitanaka.rbind.io/post/knitr-knitr-code/)) -->

---

## break_type = "auto"

One parameter of flipbooking is the break_type.  The default is "auto", in which appropriate breakpoints are determined automatically --- by finding where parentheses are balanced. 

<!-- display the user input code as a refresher -->
```{r, code = knitr::knit_code$get("cars"), eval = FALSE, echo = TRUE}
```


---

`r chunk_reveal("cars", break_type = "auto")`

---


```{css, eval = TRUE, echo = FALSE}
.remark-code{line-height: 1.5; font-size: 80%}
```
4

1 回答 1

0

包开发人员建议我尝试在“汽车”块中添加tibble() %>%之后,因为数据集很大。它仍然失败:covid %>%covid

covid %>%
tibble() %>%
...

但与

covid %>% tibble() %>%
...
于 2020-05-10T22:00:46.430 回答