如何使用在Shiny_prerendered文档的“服务器启动”上下文中创建的连接对象?我遵循了https://rmarkdown.rstudio.com/authoring_shiny_prerendered.html#context=%E2%80%98server-start%E2%80%99
中的描述但是这表示找不到con
对象。下面的代码给出了错误
从第32-34行退出(shiny_prerendered-server-start.Rmd)错误 在tbl(con,“ mtcars”)中:找不到对象'con'调用:... withCallingHandlers-> withVisible-> eval-> eval-> tbl执行 停止
---
title: "shiny_prerendered server-start"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
editor_options:
chunk_output_type: console
runtime: shiny_prerendered
---
```{r, include=FALSE, context="setup"}
rm(list = ls())
library(flexdashboard)
library(shiny)
library(RJDBC)
library(DBI)
library(tidyverse)
library(magrittr)
library(dbplyr)
library(dplyr, warn.conflicts = FALSE)
```
```{r, context="server-start"}
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
copy_to(con, mtcars)
```
```{r, context="data"}
mtcars2 <- tbl(con, "mtcars")
mtcars2_c = mtcars2 %>% collect()
```
# mtcars2
### Table
```{r, context="server"}
output$mtcars2_o = renderDataTable({
return(mtcars2_c)
})
```
```{r, context="render"}
dataTableOutput("mtcars2_o")
```