是否可以在流水线shiny::render*
的末尾使用%>%
函数族?具体来说,当将html_notebook
与runtime: shiny
一起使用时。
可以代替renderTable({mtcars[1:5, ]})
来做:mtcars[1:5, ] %>% renderTable()
吗?
示例
---
title: "R Notebook"
output: html_notebook
runtime: shiny
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.
```{r echo=FALSE, warning=FALSE, message=FALSE}
library(tidyverse)
renderTable({
mtcars[1:5, ]
})
```
```{r echo=FALSE}
renderTable({
mtcars %>%
filter(cyl == 4) %>%
group_by(am) %>%
summarise(avg_gear = mean(gear),
sd_carb = sd(carb))
})
# NOTE: This does not work!
mtcars %>%
filter(cyl == 4) %>%
group_by(am) %>%
summarise(avg_gear = mean(gear),
sd_carb = sd(carb)) %>%
renderTable()
```
答案 0 :(得分:0)
mtcars %>%
filter(cyl == 4) %>%
group_by(am) %>%
summarise(avg_gear = mean(gear),
sd_carb = sd(carb)) %>%
renderTable(quoted = TRUE) # quoted defaults to FALSE