小编and*_*eas的帖子

在gganimate中有许多(> 50)个状态的问题

我正在尝试使用gganimate覆盖90年的数据集来创建GIF ,即我希望GIF运行90个州/年.然而,似乎gganimate只能处理不到50个州.

所以这是一个例子:

library(tidyverse)
# devtools::install_github('thomasp85/gganimate')
library(gganimate)

df = expand.grid(  x = 1,
                   y = c(2,3),
                year = 1670:1760) %>% mutate( z = 0.03* year,
                                              u = .2 * year)
Run Code Online (Sandbox Code Playgroud)

这一切都运作49年:

ggplot(data=df %>% filter(., year %in% 1670:1719) , aes()) + 
  geom_point( aes(x = x, y = y, fill = z, size = u), shape = 21 ) + 
  labs( title = 'Year: {closest_state}') +
  enter_appear() +
  transition_states(year, transition_length = 1, state_length = 2) 
Run Code Online (Sandbox Code Playgroud)

例1

然而,当我包括50(或更多)年时,它变得奇怪:

ggplot(data=df %>% …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 gganimate

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

在四开本中使用 kable 在表格中使用 Markdown 格式

使用 quarto 的 HMTL 输出功能,我尝试从 data.frame 生成一个 kable,其中包含一些应显示在最终文档中的 Markdown 样式格式。在实际用例中,我有许多文档已经以这种方式格式化,我想重新使用这些命令来正确呈现输出。

这是我的example.qmd

---
title: "example"
format: 
  html
---

```{r setup}
library(kableExtra)
```

```{r}
#| echo: false
data.frame(Function = "`read_delim()`",
           Formula = "$\\leftarrow$",
           Break = "this continues on a<br>new line",
           Link = "[Google](www.google.com)") |>
  kbl(format = "html") 
```
Run Code Online (Sandbox Code Playgroud)

运行该块后,RStudio 中的预览确实正确显示了箭头和换行符,但 ` ` 和链接无法生效:

RStudio 的屏幕截图

将 qmd 渲染为 HTML 时,结果如下所示,即忽略格式:

在此输入图像描述

我缺少什么?将四开文档渲染为 HTML 时,有没有办法将此类格式化命令包含到 kable 中?

markdown r r-markdown kable quarto

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

标签 统计

r ×2

gganimate ×1

ggplot2 ×1

kable ×1

markdown ×1

quarto ×1

r-markdown ×1