Предполагая, что:
---
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Blah Blah
```{r cars}
summary(cars)
```
```{r pressure, echo=FALSE}
plot(pressure)
```
```{r}
xdf <- rbind.data.frame(mtcars, mtcars)
library(tidyverse) # rly bad place to put this but it's just a demo
just6 <- filter(xdf, cyl == 6)
```
```{r}
ggplot(mtcars, aes(wt, mpg)) + geom_point()
```
```{r}
count(just6, gear)
```
и файл с именем "forso.Rmd", который связан с "forso.html":
library(rvest)
pg <- read_html("forso.html")
html_nodes(pg, "pre.r") %>%
html_text() %>%
styler::style_text() %>%
write_lines("my-recovered-r-code.R") %>%
cat(sep="\n")
## summary(cars)
## xdf <- rbind.data.frame(mtcars, mtcars)
##
## library(tidyverse) # rly bad place to put this but it's just a demo
## just6 <- filter(xdf, cyl == 6)
## ggplot(mtcars, aes(wt, mpg)) + geom_point()
## count(just6, gear)
«##
» выше - просто артефакт вывода.
ПРИМЕЧАНИЕ , что вы не сможете вернуть код include=FALSE
или echo=FALSE
(как показано выше).
Также обратите внимание , что использование styler
на 100% необязательно.