gpt4 book ai didi

r - 浏览器刷新后交互式 rmarkdown 文档无法正确显示

转载 作者:行者123 更新时间:2023-12-04 11:52:00 25 4
gpt4 key购买 nike

我正在运行以下交互式 rmarkdown 文档:

### Example of shiny app

```{r, echo = FALSE, eval = TRUE}
numericInput("rows", "How many cars?", 5)

renderTable({
head(cars, input$rows)
})
```

### Another example

```{r, echo = FALSE}
sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30)

renderPlot({
x <- faithful[, 2] # Old Faithful Geyser data
bins <- seq(min(x), max(x), length.out = input$bins + 1)

# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
```

保存为minimal.Rmd,我通过运行来运行它
rmarkdown::run("minimal.Rmd")

在 R 控制台上。运行后,文档在浏览器上正确显示:

App displayed correctly

刷新浏览器后,文档如下所示:

App displayed incorrectly

(我已经在 chrome 和 safari 上试过了)

我注意到,当我在保存 .Rmd 文件后立即运行 rmarkdown::run 时,我在 R 控制台上得到了类似 knitr 的输出,并且文档显示正确;在不重新保存文件的情况下运行 rmarkdown::run 时,不会在控制台上产生类似 knitr 的输出,并且文档显示不正确。这可能与 rmarkdown::run 缓存有关。我得到的类似 knitr 的输出是:
Listening on http://127.0.0.1:6381


processing file: minimal.Rmd
|................ | 25%
|................................ | 50%
|................................................. | 75%
|.................................................................| 100%
label: unnamed-chunk-2 (with options)
List of 1
$ echo: logi FALSE


output file: /var/folders/15/q9z0km897fs93f_z1slpf09h0000gp/T//Rtmpt7kc98/minimal.knit.md

/usr/local/bin/pandoc /var/folders/15/q9z0km897fs93f_z1slpf09h0000gp/T//Rtmpt7kc98/minimal.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /var/folders/15/q9z0km897fs93f_z1slpf09h0000gp/T/rmarkdown/rmd_b468d17c42847143a4499f693d7a0f45.html --smart --email-obfuscation none --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rmarkdown/rmd/h/default.html --variable theme:bootstrap --mathjax --variable mathjax-url:https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML --no-highlight --variable highlightjs=rmd_b468d17c42847143a4499f693d7a0f45_files/highlight

Output created: /var/folders/15/q9z0km897fs93f_z1slpf09h0000gp/T/rmarkdown/rmd_b468d17c42847143a4499f693d7a0f45.html
Warning in addResourcePath(prefix, dependency$src$file) :
Overriding existing prefix rmarkdown-performance-0.1 => /private/var/folders/15/q9z0km897fs93f_z1slpf09h0000gp/T/rmarkdown/rmd_54619711603ff951c709d43a6cda206b_files

我的 session 信息是:
sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] shiny_0.10.0 rmarkdown_0.2.46

loaded via a namespace (and not attached):
[1] bitops_1.0-6 caTools_1.17 digest_0.6.4 evaluate_0.5.5 formatR_0.10 htmltools_0.2.4
[7] httpuv_1.3.0 knitr_1.6 Rcpp_0.11.2 RJSONIO_1.2-0.2 stringr_0.6.2 tools_3.1.0
[13] xtable_1.7-3

最佳答案

添加:
---
runtime: shiny
output: html_document
---

到文档顶部修复了问题。 Answered由 Fereshteh Karimeddini 在 Shiny users Google 群组中撰写。

关于r - 浏览器刷新后交互式 rmarkdown 文档无法正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24930283/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com