kbodwin / demoR

(this package has been replaced by "flair")
https://kbodwin.github.io/flair/index.html
Other
47 stars 7 forks source link

Bug Report: Error in base::file #12

Closed JiaxiangBU closed 5 years ago

JiaxiangBU commented 5 years ago

Here is the reproducible minimal example.

library(demoR)
library(tidyverse)
demo_code('

iris %>%
  group_by(Species) %>%
  summarize(mean(Sepal.Length))

') %>%
  hlt_fixed("%>%")
iris %>%
group_by(Species) %>%
summarize(mean(Sepal.Length))
#> # A tibble: 3 x 2
#>   Species    `mean(Sepal.Length)`
#>   <fct>                     <dbl>
#> 1 setosa                     5.01
#> 2 versicolor                 5.94
#> 3 virginica                  6.59

Created on 2019-08-08 by the reprex package (v0.2.1)

image

It works well when I choose reprex to make a reproducible example. However, when I run the same code in a chunk of a Rmd document, I get this sort of error.

Error in base::file(file, encoding = encoding) : 'description'参数不对
```{r}
library(demoR)
library(tidyverse)
demo_code('

iris %>%
  group_by(Species) %>%
  summarize(mean(Sepal.Length))

') %>%
  hlt_fixed("%>%")


Here is the screenshot.

![image](https://user-images.githubusercontent.com/15884785/62702817-5c2ed580-ba1a-11e9-99cb-e3a35c0029b9.png)
kbodwin commented 5 years ago

Thank you so much for the heads up and the reprex!

I believe this is now fixed by 0edd78a774b35f48c76add4a2a65651d6231ed50

JiaxiangBU commented 5 years ago

It works with both reprex and rmarkdown::render.

library(demoR)
library(tidyverse)
#> Warning: 程辑包'ggplot2'是用R版本3.5.3 来建造的

#> Warning: 程辑包'tibble'是用R版本3.5.3 来建造的

#> Warning: 程辑包'tidyr'是用R版本3.5.3 来建造的

#> Warning: 程辑包'purrr'是用R版本3.5.3 来建造的

#> Warning: 程辑包'dplyr'是用R版本3.5.3 来建造的

#> Warning: 程辑包'stringr'是用R版本3.5.3 来建造的

#> Warning: 程辑包'forcats'是用R版本3.5.3 来建造的
demo_code('

iris %>%
  group_by(Species) %>%
  summarize(mean(Sepal.Length))

') %>%
  hlt_fixed("%>%")
iris %>%
group_by(Species) %>%
summarize(mean(Sepal.Length))
#> # A tibble: 3 x 2
#>   Species    `mean(Sepal.Length)`
#>   <fct>                     <dbl>
#> 1 setosa                     5.01
#> 2 versicolor                 5.94
#> 3 virginica                  6.59

Created on 2019-08-09 by the reprex package (v0.2.1)

---
author: Jiaxiang Li
date: "`r Sys.Date()`"
output: html_document
---

```{r}
library(demoR)
library(tidyverse)
demo_code('

iris %>%
  group_by(Species) %>%
  summarize(mean(Sepal.Length))

') %>%
  hlt_fixed("%>%")


![image](https://user-images.githubusercontent.com/15884785/62765692-37db0380-bac3-11e9-99c2-27096d97231a.png)

Thanks a lot! @kbodwin