我尝试使用rmarkdown进行编译时从具有ggplot图的嵌套列中删除索引号。我曾尝试更改块选项,但我不认为答案在那里。我读到cat()
可能有效,但不确定如何包括在内。
这里是代表:
---
title: "test"
output: pdf_document
---
```{r setup, include=FALSE}
library(ggplot2)
library(purrr)
library(knitr)
library(tinytex)
knitr::opts_chunk$set( warning = FALSE, message = FALSE, comment = NA)
df <- iris %>%
group_by(Species) %>%
nest() %>%
mutate(
plot= purrr::map(data, ~ ggplot(., aes(Sepal.Length, Sepal.Width)) + geom_point()))
```
```{r}
df %>%
filter(Species == "setosa") %>%
select(plot) %>%
pull()
```
将不胜感激。
最佳
我们可以pluck
list
元素
library(dplyr)
library(purrr)
df %>%
filter(Species == "setosa") %>%
ungroup %>%
pull(plot) %>%
pluck(1)
或者可以通过]使它更简单>
df %>%
filter(Species == "setosa") %>%
ungroup %>%
pluck("plot", 1)