小编Kev*_* Ho的帖子

如何使用 r-markdown 编织与多行文本对齐的内嵌图像?

我想编一个报告,使标题类似于下图。

  • 最左边的方块是一个图标
  • 矩形是文本

我目前遇到三个问题

  1. 如何插入带有网址的图标(在线图片)?
  2. 如何格式化图标,使其与 3 行文本内联
  3. 如何更改行之间的字体大小和行距

在此处输入图片说明

请在下面找到最小的可重现示例(请注意,我对在线图像进行了评论,因为我不知道如何正确编码)

---
output: pdf_document
geometry: margin=0.25in
classoption:
  - landscape
---

```{r, echo=FALSE, results='asis'}
for (i in unique(iris$Species)) {
  cat("\\newpage")
  # cat('\n![](https://bookdown.org/yihui/rmarkdown/images/hex-rmarkdown.png)\n')
  cat("\n#", "Iris Species Summary", "\\hfill", paste0("Exhibit ", grep(i, unique(iris$Species)), ".1"))
  cat("\n##", i, "\\hfill", "(Gross)")
  cat("\n######", "(000's)", "\\hfill", as.character(Sys.Date()))
}
```
Run Code Online (Sandbox Code Playgroud)

r knitr r-markdown

10
推荐指数
1
解决办法
603
查看次数

如何在 r markdown 中将 kable 和 ggplot 排成一行(并排)?

我正在尝试将 r markdown 文件编织为pdf,但我无法将 ggplot 和 kable 对齐在一行中。

我尝试了以下方法:

  • 猫(“\双列”)
  • kable_styling(position = "float_right")

下面是一个最小的、可重现的例子

---
title: "Untitled"
output: pdf_document
classoption: landscape
---

\newpage

```{r cars, echo=FALSE, fig.width=3, fig.height=3, results="asis", message=FALSE}
library(dplyr)
library(knitr)
library(kableExtra)
library(ggplot2)

dt <- split(mtcars, f = mtcars[, "cyl"]) %>% lapply(., function(x) x[1:5, 1:4])

for (i in seq_along(dt)) {

  print(
    kable(dt[[i]]) %>% kable_styling("striped") %>% add_header_above(c(" " = 1, "Group 1" = 2, "Group 2" = 2))
  )

  print(
    ggplot(data = dt[[i]], aes(x = mpg, y = …
Run Code Online (Sandbox Code Playgroud)

latex r ggplot2 knitr r-markdown

2
推荐指数
1
解决办法
753
查看次数

如何安全地加密 R 中的字符串?

如何安全地加密R中的字符串,使其无法进行反向解密?


更新@11/21/2019

我不需要密钥来加密字符串。

目标是即使有人可以查看我的代码和加密字符串,他们也无法检索原始字符串。


我使用的是openssl包,如下所示

library(openssl)

md5("example")
Run Code Online (Sandbox Code Playgroud)

请注意,问题已根据 James 的评论进行了更改,原来的问题是What is the most secure way to encrypt a string in R?

encryption r

1
推荐指数
1
解决办法
2104
查看次数

标签 统计

r ×3

knitr ×2

r-markdown ×2

encryption ×1

ggplot2 ×1

latex ×1