我有一个正常运行的Shiny交互式文档(.Rmd)文件,可以在本地和shinyapps.io上正常工作。我试图使用这里的指令(http://rmarkdown.rstudio.com/authoring_shiny_prerendered.html)来预渲染它,但是当我引入selectInput()时遇到了一个异常错误。
我得到的错误是: lexical error: invalid character inside string.
这是产生错误的最小代码块。
(app.Rmd)
---
title: 'a title'
output: html_document
runtime: shiny_prerendered
---
```{r, context = 'setup', include=FALSE}
library(shiny)
```
```{r, context='render'}
selectInput('hello','Hi',choices=c('1','2'))
```
```{r, context='server'}
```
这是我的sessionInfo():
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shiny_1.0.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.6 digest_0.6.10 rprojroot_1.1 mime_0.5 R6_2.1.2 xtable_1.8-2 backports_1.0.3
[8] magrittr_1.5 evaluate_0.10 stringi_1.1.1 rmarkdown_1.3 tools_3.2.2 stringr_1.1.0 httpuv_1.3.3
[15] yaml_2.1.13 htmltools_0.3.5 knitr_1.15.1
我尝试将我的Rmd的编码更改为UTF-8而没有运气。将运行时更改为"有光泽" (来自" shiny_prerendered")似乎解决了这个问题。这是" shiny_prerendered"中的错误吗?运行时还是我做错了什么?