下面的文档运行 sql 并显示结果。我不希望通过不运行块或隐藏输出来显示任何输出。
有没有办法做到这一点?
---
output: html_document
---
## Hide SQL Output
First, set up a temporary database:
```{r}
library(RSQLite)
conn <- dbConnect(SQLite(), tempfile())
df <- data.frame(value = runif(1))
dbWriteTable(conn, "TestTable", df)
```
Now show a query, but try not to run it, and try
to hide the output. Neither works: it runs, and
displays the table.
```{sql connection = conn,results="hide",eval=FALSE}
SELECT * FROM TestTable;
```
Run Code Online (Sandbox Code Playgroud)
我想使用 bookdown 将一系列.Rmd文件解析为一本书。如果我.Rmd的目录与主index.Rmd文件位于同一目录中,那么一切正常且花花公子。但是,这些.Rmd文件是从另一个来源自动生成的,我想将输入文件保存在一个子目录中。有可能这样做吗?
我可以在其中包含文件名,_bookdown.yml但我不希望每次.Rmd添加新文件时都更新该文件。
当前版本_bookdown.yml看起来像这样
new_session: yes
rmd_files:
html: ["input/index.Rmd", "input/01-file.Rmd"]
latex: ["input/index.Rmd", "input/01-file.Rmd"]
Run Code Online (Sandbox Code Playgroud)
我可以在脚本中移动文件,但希望它可以通过bookdown它自己实现。
Bookdown 是一个很棒的软件包,我很期待看到它是如何发展的,但是现在我pdf_document2在以附录形式呈现图形编号时遇到了麻烦。特别是当带有标题的图形在附录中时,图形编号应采用 A.1、A.2、B.1、B.2 等形式,但图形编号被视为带有编号 3.1 的正常部分, 3.2、4.1、4.2等,其中附录分别为第三和第四节。下面是一个例子:
---
title: "Untitled"
author: "John Doe"
date: "November 18, 2016"
documentclass: article
output:
bookdown::pdf_document2:
toc: yes
fig_caption: yes
number_sections: yes
linkcolor: blue
---
# Chapter One
```{r a, fig.cap="rabble rabble"}
plot(cars) # a scatterplot
```
```{r b, fig.cap="rabble rabble"}
plot(cars) # a scatterplot
```
# Chapter Two
# (APPENDIX) Appendix {-}
# Appendix A
```{r c, fig.cap="rabble rabble"}
plot(cars) # a scatterplot
```
# Appendix B
```{r d, fig.cap="rabble rabble"}
plot(cars) …Run Code Online (Sandbox Code Playgroud) 我升级到RStudio 1.0.44,似乎knitr :: opts_knit $ set(root.dir = path)其中path是我的目录不像以前那样工作.它抛出一条消息:
The working directory was changed to /... inside a notebook chunk. The working
directory will be reset when the chunk is finished running. Use the knitr
root.dir option in the setup chunk to change the the working directory for
notebook chunks.
Run Code Online (Sandbox Code Playgroud)
此消息现在将出现在以下每个命令中.请注意,我还没有编织rmd.我只是在运行命令.通过setwd()直接在命令行中设置工作目录会返回getwd()中的正确路径,但是再次加载具有相对路径(./ ...)的文件将返回上面的消息.RStudio 0.99.896完全相同的rmd工作正常.我错过了什么?
sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
>Running under: Windows 7 x64 (build 7601) Service Pack 1
other attached packages:
[1] scales_0.4.0 ggplot2_2.1.0 xtable_1.8-2 data.table_1.9.6
[5] dplyr_0.4.3 …Run Code Online (Sandbox Code Playgroud) 我喜欢在我的 r bookdown 项目中使用引文。
格式不是很灵活,我可以使用@citeID 获取“作者(年份)”或[@citeID] 获取“(作者年份)”。
有时我只需要“(Year)”或“Year”,或者我可能只需要“Author Year”,根本不需要括号。
最后,我需要添加对引文的页面引用,例如“作者(年份:页面)”
任何人都可以给我一个提示,相关代码在源代码中的位置,以便我可以开始添加一些上述引用格式?
这是一个 R -> Latex 问题。\n我使用 tufte_handout
\n\n我需要将全角表格的标题放在表格下方的页边距中,因为表格太宽了。
\n\n\n\n这是 Rmarkdown 文件
\n\n---\ntitle: "Untitled"\nauthor: "A. Nonymous"\ndate: "19/8/2017"\nheader-includes:\n - \\usepackage{array}\noutput:\n tufte::tufte_handout:\n citation_package: natbib\n keep_tex: yes\n latex_engine: xelatex\n---\n\n```{r setup, include=FALSE}\nlibrary(tidyverse)\nlibrary(tibble)\nlibrary(knitr)\nlibrary(kableExtra)\nlibrary(tufte)\n\nknitr::opts_chunk$set(echo = TRUE)\n\noptions(knitr.table.format = "latex") \n```\n\n\n# table\n\n\n```{r table-1, fig.fullwidth=T, echo=FALSE}\n\ntmp <- tibble(`long titre de texte de colonne` = 1:3, \n `encore un long titre de colonne` = 101:103,\n `c\'est tr\xc3\xa8s long l\xc3\xa0 aussi (trop)`=31:33, \n `mais pourquoi est-ce si long ? (oui, pourquoi?)`=c("a","b","b"))\ntmp <- as.data.frame(tmp)\n\nknitr::kable(tmp,booktabs=TRUE,caption="test de test de table, mais c\'est …Run Code Online (Sandbox Code Playgroud) 的最大可接受值是多少fig.width?看起来传递超过 12 的值是无效的。我一直在测试 HTML 输出的图形高度和宽度的不同值。我确保宽度值始终不小于高度。
我喜欢调整Bookdown、Gitbook 样式HTML 文档的目录样式(例如背景颜色、字体)。这可能吗?如果是这样,有人可以好心地指出我可以从哪里开始这样做吗?谢谢。
我有一个 knitr 程序,可以在浏览器页面中呈现为 html。我想在输出打开的浏览器选项卡中放置一个 favicon .png 图像。
我已经用闪亮但不是独立的 knitr 看到了这个问题的答案
我正在渲染两个文档,这些文档相互交叉引用。为此,我正在使用 LaTeX 包zref。
为了zref工作,它需要*.aux调用时创建的文档的文件pdflatex。
不幸的是,使用 RStudio 及其基本方法来渲染文档(编织按钮,Cmd+Shift+K 或rmarkdown::render()),这些文件将在编译成功后被删除。
取消选中全局选项工具 -> 全局选项 -> Sweave -> 编译后清理辅助输出无济于事。
我知道有两种选择可以解决这个问题:
在 pdf 渲染后手动编译 tex 文件。
编写一个执行此操作的 makefile。
但是还有我不知道的另一种选择吗?