我正在使用Windows 7,R2.15.3和RStudio 0.97.320与knitr knitr_1.1.6(在Yihui于3月12日修复'编码:编织和子文件'问题后下载)
> sessionInfo()
R version 2.15.3 (2013-03-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=Spanish_Argentina.1252 LC_CTYPE=Spanish_Argentina.1252 LC_MONETARY=Spanish_Argentina.1252
[4] LC_NUMERIC=C LC_TIME=Spanish_Argentina.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lattice_0.20-13 pixmap_0.4-11 RColorBrewer_1.0-5 ade4_1.5-1 pander_0.3.1
[6] xtable_1.7-1
loaded via a namespace (and not attached):
[1] digest_0.6.3 evaluate_0.4.3 formatR_0.7 grid_2.15.3 knitr_1.1.6 stringr_0.6.2 tools_2.15.3
Run Code Online (Sandbox Code Playgroud)
我把R代码放在像这样的文件中:
## @knitr RunMyCode
print('Called from .R file: á é í ó ú ñ')
# Workaround
my.text <- 'á é í ó …Run Code Online (Sandbox Code Playgroud) 我正在使用knitr 1.1.在R 3.0.0和WinEdt(RWinEdt 2.0)中.我遇到了knitr识别瑞典字符(ä,ö,å)的问题.这不是R的问题; 这些字符甚至可以在文件名,目录名,对象等中识别.在Sweave中,它也不是问题.
我已经\usepackage[utf8]{inputenc}在我的文档中,但knitr似乎无法处理特殊字符.运行knitr后,我收到以下消息:
Warning in remind_sweave(if (in.file) input) :
It seems you are using the Sweave-specific syntax; you may need Sweave2knitr("deskriptiv 130409.Rnw") to convert it to knitr
processing file: deskriptiv 130409.Rnw
(*) NOTE: I saw chunk options "label=läser_in_data"
please go to http://yihui.name/knitr/options (it is likely that you forgot to
quote "character" options)
Error in parse(text = str_c("alist(", quote_label(params), ")"), srcfile = NULL) :
1:15: unexpected input
1: alist(label=lä
^
Calls: knit ... parse_params -> withCallingHandlers …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建笔记本,其中我提供了用R和Python编写的相同算法.我可以轻松地将R和Python代码集成到Rmd文件中,然后使用RStudio中的"Knit HTML"按钮创建HTML输出.但是,Python代码始终显示时没有语法突出显示(与https://github.com/yihui/knitr-examples/blob/master/023-engine-python.md中的示例不同).我安装了Andre Simon的高亮软件并在我的电脑上运行(MacBook Pro Retina,MacOS X 10.9).
目前,我在R:markdown 0.6.4,knitr 1.5.15,highr 0.3.1中安装了以下库.
知道可能是什么问题吗?谢谢你的帮助!.
我在制作ggplot2,tikzDevice和knitr时遇到了问题.我正在使用RStudio,并尝试在Latex文档中包含一些R图形.我用了一个非常简单的例子:
\documentclass{article}
\begin{document}
\begin{figure}
<<fig1,eval=TRUE,echo=FALSE,dev='tikz'>>=
library(ggplot2)
library(tikzDevice)
qplot(displ, hwy, data = mpg, colour = factor(cyl))
@
\end{figure}
\end{document}
Run Code Online (Sandbox Code Playgroud)
但是没有输出pdf,我收到以下错误消息:
Error in getMetricsFromLatex(TeXMetrics) :
TeX was unable to calculate metrics for the following string
or character:
hwy
Common reasons for failure include:
* The string contains a character which is special to LaTeX unless
escaped properly, such as % or $.
* The string makes use of LaTeX commands provided by a package and
the tikzDevice was not told to load …Run Code Online (Sandbox Code Playgroud) 如何在rmarkdown生成的pdf_document中获取我的表浮动的标题?
运用
output:
pdf_document:
fig_caption: true
Run Code Online (Sandbox Code Playgroud)
和
```{r, fig.cap='a caption'}
myplot
```
Run Code Online (Sandbox Code Playgroud)
使用myplot和指定的标题生成浮动数字.
如何使用xtable生成的表实现相同的功能?
```{r, results='asis', fig.cap='table caption'}
print(xtable(table), comment = FALSE)
```
Run Code Online (Sandbox Code Playgroud)
我曾尝试在print.xtable中使用floating.environment ='figure',但无济于事.
有没有办法报告计算每个块需要多少时间?我正在从一些大型脚本创建一个文档,很高兴知道时间在哪里.我确实使用了缓存功能,所以当缓存对象时,使用文档的速度并不太慢,但我想隔离缓慢的块,看看除非绝对需要,否则我可以阻止它们被重新计算.
一种想法是例如将每个块包装在system.time()中并报告每个块输出下面的system.time,或者在边缘...
再次感谢Yihui这样优秀的软件.
Bootswatch 的文档建议我可以使用选项卡集中选项卡的下拉菜单:
如何使用 Rmarkdown 实现这一目标?我试过了:
# SECTION 1 {.tabset .tabset-fade}
## Section 1.1
## Section 1.2 {????something here?????}
### Section 1.2.1 <<<<<<<<< want this to appear under the dropdown menu
Run Code Online (Sandbox Code Playgroud) 我正在使用 Bookdown 和 Rmarkdown 为 Stata 用户编写一本技术书籍。我想在代码块中包含 Stata 高亮语法,但我对从 Rstudio 实际执行 Stata 不感兴趣。我只想要语法高亮。
我在这里了解到可以使用highlightjs但我不知道如何将它包含在我的 .Rmd 文件中。
我希望能够包含以下内容并突出显示它的语法。
```stata
sysuse auto, clear
reg mpg length
```
Run Code Online (Sandbox Code Playgroud)
我非常感谢您的帮助。谢谢。
我有一个简单的 bookdown 项目,其中包含几个 Rmd 文件,每章一个文件加上一个 index.Rmd。
---
title: Title
author: My name
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
---
Run Code Online (Sandbox Code Playgroud)
# Some stuff
Run Code Online (Sandbox Code Playgroud)
ETC...
我希望我的索引文件大部分为空,因为所有章节文件都是可以互换的,至少现在是这样。我不打算做任何简短的介绍。我可能想添加一些前言,但这会破坏一切。Bookdown 希望我从索引中的一章开始。Rmd
我可以毫无问题地生成 pdf 和 epub,但对于 html 或 gitbook,我收到错误:
在 split_chapters(output, gitbook_page, number_sections, split_by, : 你有 6 个 Rmd 输入文件,但只有 5 个一级标题。你是否忘记了某些 Rmd 文件中的一级标题?
生成的书仅包含一条错误消息:
找不到/home/milo/Documents/bookdown_project/_book/index.html