flipbookr 中的文本清理

问题描述 投票:0回答:1

我使用了最小的

flipbookr
模板,并喜欢用旁边的代码逐行说明一些文本清理步骤。这是我的代码块:

library(tidyverse)
library(tidytext)
library(stringr)
library(wikifacts)

R_EN <- wiki_define('R (programming language)')
R_EN #BREAK

R_EN %>% 
    ## Remove digits
    str_remove_all("[:digit:]") %>% #BREAK
    ## Remove punctuation
    str_remove_all("[[:punct:]]") %>% #BREAK
    ## Make everything lowercase
    str_to_lower() %>% #BREAK
    ## Remove any trailing whitespace around the text
    str_trim("both") %>% #BREAK
    ## Remove newline character
    str_replace_all("[\r\n]" , " ") #BREAK

右侧仅显示前几个单词(编译后的 markdown)。如何让长字符的所有(或至少更多)行出现?

就像他们在控制台中所做的那样:

r tidyverse flipbookr
1个回答
0
投票

这段代码怎么样:

---
title: "A flipbook"
subtitle: "With flipbookr and xaringan"
author: "Manoj Kumar"
output:
  xaringan::moon_reader:
    lib_dir: libs
    css: [default, hygge, ninjutsu]
    nature:
      ratio: 16:9
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
---


```{r, 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 scratch can be time consuming
knitr::opts_chunk$set(fig.width = 6, message = FALSE, warning = FALSE, comment = "", cache = F)

# devtools::install_github("EvaMaeRey/flipbookr")
# install.packages("xaringan", dependencies = T)

library(flipbookr)
library(tidyverse)
library(tidytext)
library(stringr)
library(wikifacts)

R_EN <- wiki_define('R (programming language)')
```


`r chunk_reveal("my_wiki")`


```{r my_wiki, include = FALSE, warning=FALSE}

R_EN #BREAK
```


`r chunk_reveal("my_wiki1")`

```{r my_wiki1, include = FALSE, warning=FALSE}
R_EN %>% 
    ## Remove digits
    str_remove_all("[:digit:]") %>% #BREAK
    ## Remove punctuation
    str_remove_all("[[:punct:]]") %>% #BREAK
    ## Make everything lowercase
    str_to_lower() %>% #BREAK
    ## Remove any trailing whitespace around the text
    str_trim("both") %>% #BREAK
    ## Remove newline character
    str_replace_all("[\r\n]" , " ") #BREAK
```




<!-- adjust font size in this css code chunk, currently 80 -->

```{css, eval = TRUE, echo = FALSE}
.remark-code{
    line-height: 1.5; 
    font-size: 80%; 
    white-space: pre-wrap;
    /* width: 400px; */ /* Adjust the width as needed */
    width: 80%; /* Adjust the percentage as needed */
    overflow-x: auto;
    }

@media screen and (max-width: 600px) {
    .remark-code {
        width: 100%; /* Adjust for smaller screens */
        white-space: pre-wrap;
    }
}

@media print {
  .has-continuation {
    display: block;
    overflow-x: auto !important;
  }
}

code.r.hljs.remark-code{
  position: relative;
  overflow-x: hidden;
}


code.r.hljs.remark-code:hover{
  overflow-x:visible;
  width: 500px;
  border-style: solid;
}
```

这将给出如下快照所示的换行文本:

还有

如果这对您有帮助,请告诉我...

© www.soinside.com 2019 - 2024. All rights reserved.