Flipbookr中的文本清理

suzh9iv8  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(76)

我使用了最小的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)。我如何才能使一个长字符的所有(或至少更多)行显示出来?


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

fhity93d

fhity93d1#

这段代码怎么样:

---
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_EN #BREAK

r chunk_reveal("my_wiki1")

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
.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;
}
字符串
这将使文本如下面的快照所示进行 Package :

![](https://i.stack.imgur.com/PALfi.png)
的数据
和

![](https://i.stack.imgur.com/pKjtI.png)

请让我知道如果这对你有帮助...

相关问题