kableExtra::text_spec - 旋转文本 - 不需要的逗号
kableExtra::text_spec - Rotate Text - Unwanted Commas
使用 RSTudio > Blogdown > Hugo 创建博客
将此 R 插入 post。当呈现 HTML 时,旋转字母之间有逗号。这是为什么?
library("knitr")
library("kableExtra")
library("dplyr")
library("formattable")
library("stringr")
library("tidyverse")
p1 <- c("R Markdown is pretty neat. You can do things like this. I wonder why more people don't")
p1 <- c("Hello World!")
p2 <- c("do this. It's so much easier to read. NOTE: Those people live here.")
p_text <- unlist(strsplit(p1, "")) # strsplit returns a list. Make it a vector.
num_char <- length(p_text)
p_angle <- seq(30, 360, 30)
num_ang <- length(p_angle)
p_angle_long <- rep(p_angle, ceiling(num_char / num_ang)) # Repeat the angles for the length of the string
p_angle_long <- p_angle_long[1:num_char]
rtext <- text_spec(p_text, "html", bold = TRUE, angle = p_angle_long)
text_spec
的输出是一个向量,每个字母(+ 伴随 HTML 标签)作为一个单独的元素。您可以使用 paste0
:
组合成一个字符串
# Example RMarkdown chunk that produces rotated text:
```{r txt, results='asis'}
library("knitr")
library("kableExtra")
library("tidyverse")
p1 <- c("Hello World!")
p2 <- c("do this. It's so much easier to read. NOTE: Those people live here.")
p_text <- unlist(strsplit(p1, "")) # strsplit returns a list. Make it a vector.
num_char <- length(p_text)
p_angle <- seq(30, 360, 30)
num_ang <- length(p_angle)
p_angle_long <- rep(p_angle, ceiling(num_char / num_ang))
# Repeat the angles for the length of the string
p_angle_long <- p_angle_long[1:num_char]
rtext <- text_spec(p_text, "html", bold = TRUE, angle = p_angle_long)
cat(paste0(rtext, collapse=""))
```
使用 RSTudio > Blogdown > Hugo 创建博客 将此 R 插入 post。当呈现 HTML 时,旋转字母之间有逗号。这是为什么?
library("knitr")
library("kableExtra")
library("dplyr")
library("formattable")
library("stringr")
library("tidyverse")
p1 <- c("R Markdown is pretty neat. You can do things like this. I wonder why more people don't")
p1 <- c("Hello World!")
p2 <- c("do this. It's so much easier to read. NOTE: Those people live here.")
p_text <- unlist(strsplit(p1, "")) # strsplit returns a list. Make it a vector.
num_char <- length(p_text)
p_angle <- seq(30, 360, 30)
num_ang <- length(p_angle)
p_angle_long <- rep(p_angle, ceiling(num_char / num_ang)) # Repeat the angles for the length of the string
p_angle_long <- p_angle_long[1:num_char]
rtext <- text_spec(p_text, "html", bold = TRUE, angle = p_angle_long)
text_spec
的输出是一个向量,每个字母(+ 伴随 HTML 标签)作为一个单独的元素。您可以使用 paste0
:
# Example RMarkdown chunk that produces rotated text:
```{r txt, results='asis'}
library("knitr")
library("kableExtra")
library("tidyverse")
p1 <- c("Hello World!")
p2 <- c("do this. It's so much easier to read. NOTE: Those people live here.")
p_text <- unlist(strsplit(p1, "")) # strsplit returns a list. Make it a vector.
num_char <- length(p_text)
p_angle <- seq(30, 360, 30)
num_ang <- length(p_angle)
p_angle_long <- rep(p_angle, ceiling(num_char / num_ang))
# Repeat the angles for the length of the string
p_angle_long <- p_angle_long[1:num_char]
rtext <- text_spec(p_text, "html", bold = TRUE, angle = p_angle_long)
cat(paste0(rtext, collapse=""))
```