최근에 xaringan을 사용하기 시작했으며 정말 멋지다. 위대한 패키지에 대한 감사 Yihui. 내가 궁금해했던 한 가지 질문은, for 루프에서 플롯 플롯을 포함하는 슬라이드를 프로그래밍 방식으로 생성하는 것이 가능한가? 이것은 완벽하게 작동프로그래밍 방식으로 xaringan 및 음모로 R 슬라이드 생성
```{r, message=FALSE, warning=FALSE, results='asis'}
for (p in ggplot_list) {
cat("\n\n---\n")
print(p)
}
```
: 나는이 같은 ggplots의 슬라이드를 생성 할 수 있습니다 알고, ggplot_list는 ggplots의 목록입니다.
또한 완벽하게 작동하는 ggplotly(ggplot_list[[1]])
을 호출하여 플롯 플롯을 개별적으로 포함 할 수 있습니다.
하지만 두 작품의 조합을 얻지 못해서 순진하게 다음 작업을 수행하면 나에게 빈 슬라이드가 생성됩니다.
```{r, message=FALSE, warning=FALSE, results='asis'}
for (p in ggplot_list) {
cat("\n\n---\n")
ggplotly(p)
}
```
업데이트 : 여기에는 제가 지금까지 시도한 것들 중 최소한의 예가 포함되어 있습니다.
---
title: "xaringan + plotly + loop?"
subtitle: "Does it work?"
author: "Fenfen Kan"
date: "2017/13/32"
output:
xaringan::moon_reader:
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
```
# Several boring ggplots
```{r, message=FALSE, warning=FALSE}
library(ggplot2)
library(plotly)
p1 <- ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
geom_point(aes(color=Species))
p2 <- ggplot(iris, aes(Petal.Length, Petal.Width)) +
geom_point(aes(color=Species))
p3 <- ggplot(iris, aes(Sepal.Length, Petal.Length)) +
geom_point(aes(color=Species))
ggplot_list <- list(p1, p2, p3)
```
---
# Invididual plotly works
```{r}
ggplotly(p1)
```
---
# ggplot slides in loop also works
```{r, message=FALSE, warning=FALSE, results='asis'}
for (p in ggplot_list) {
cat("\n\n---\n")
print(p)
}
```
---
# plotly in loop doesn't work
```{r, message=FALSE, warning=FALSE, results='asis'}
for (p in ggplot_list) {
cat("\n\n---\n")
ggplotly(p)
}
```
# print(ggplotly(p)) in loop doesn't work either
```{r, message=FALSE, warning=FALSE, results='asis'}
for (p in ggplot_list) {
cat("\n\n---\n")
print(ggplotly(p))
}
```
'print (ggplotly (p)) '를 사용해 보셨습니까? –
흠, 그건 나에게도 도움이 안된다. 나는 그것을 최소한의 예제에 추가 할 것이다. –