我从RStudio中的一个新的R笔记本开始:
---
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}图书馆(微基准)
N <- 1000000 L
微基准(
排序(sample.int(N),方法=‘基’),
排序(sample.int(N),方法=“快速”),
排序(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并再次单击“针织”按钮,那么现在它看起来是正确的:

有没有办法防止RStudio搞砸我的第一个knit?
我使用的是RStudio版本1.1.419 for Windows。
发布于 2018-10-24 17:22:29
有两个变化正在发生。首先,您的html_notebook格式正在更改为html_document:格式。第二,正在添加df_print选项。
基本上,这其中的第一个就是Knit to HTML所要求的。html_document和html_notebook是不同的格式,您要求更改格式。
一旦您采用了html_document格式,您可能需要df_print: default而不是df_print: paged。或者你可以忽略这个选项。
据我所见,除了更改RStudio的源(这个文件中的第118行:https://github.com/rstudio/rstudio/blob/8af730409bb6d651cc8f6816d136bea91441e7a4/src/gwt/src/org/rstudio/studio/client/rmarkdown/model/RmdTemplateData.java)之外,没有其他方法可以要求这样做。
这对大多数人来说都不太实际。
当然,在选择了html_document输出格式之后,您可以更改该选项(或者只是删除它)。
https://stackoverflow.com/questions/52972948
复制相似问题