【发布时间】:2019-03-29 02:27:23
【问题描述】:
我从 RStudio 中的新 R Notebook 开始:
---
title: "R Notebook"
output: html_notebook
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. Etc Etc Etc.
然后我修改它来做我想做的事——例如,我正在尝试使用microbenchmark()。
---
title: "R Notebook"
output: html_notebook
---
Let's compare the sort methods on a set of shuffled integers.
```{r}
library(microbenchmark)
n <- 100000L
microbenchmark(
sort(sample.int(n),method='radix'),
sort(sample.int(n),method='quick'),
sort(sample.int(n),method='shell')
)
```
将此microbenchmark() 提交到控制台会给出合理的输出,例如:
Unit: milliseconds
expr min lq mean median uq max neval cld
sort(sample.int(n), method = "radix") 4.685707 4.914925 6.559412 5.619257 7.539383 16.66746 100 a
sort(sample.int(n), method = "quick") 8.169732 8.534512 10.490920 9.333782 11.008653 21.44854 100 b
sort(sample.int(n), method = "shell") 10.766820 11.144858 15.479061 12.408976 14.519405 133.87898 100 c
但是,当我尝试 knit 它时(单击从“预览”到“编织到 HTML”的下拉菜单,它会自动将我的标题更改为:
---
title: "R Notebook"
output:
html_document:
df_print: paged
---
这真的把输出弄乱了——现在它看起来像这样:
如果我返回并将标题改回output: html_notebook 并再次单击“Knit”按钮,现在它看起来正确:
有没有办法防止 RStudio 弄乱我的第一个 knit?
我正在使用适用于 Windows 的 RStudio 版本 1.1.419。
【问题讨论】:
-
为了后代,我已经在github.com/rstudio/rmarkdown/issues/1469 的
rmarkdown存储库中提交了这个(因为我们应该避免将微基准输出打印为分页表)
标签: r rstudio knitr microbenchmark rnotebook