knitr

R anchors in markdown

大憨熊 提交于 2019-12-04 02:59:30
问题 In creating a Rmd file I included an internal hyperlink: [hlink](#id1) and then further on an anchor <a id="id1"></a> . When I then use Knit HTML (in RStudio) everything works fine and the internal hyperlink works fine but I also get an unwanted � <p><a id="id1"></a>�</p> How can I avoid getting this error? 回答1: I was just looking for a solution to produce a table of content and came across your question. The above example works perfectly fine. No unwanted side effects. My session info: R

non-evaluated vignettes with knitr::rmarkdown_notangle

一世执手 提交于 2019-12-04 02:38:38
The knitr package has relatively recently added new notangle vignette engines, such as knitr::rmarkdown_notangle , that allow disabling of evaluation of vignette chunks. The general process of using knitr for vignettes is described here , while the specific notangle functionality is described in an answer to this question . My problem is that I can't get this to work. I can get it to pass R CMD build by including the .html output in the vignettes directory (I also put a copy in inst/doc ), but I can't get it to pass R CMD check unless I specify --no-build-vignettes , or unless I change the

Insert manually created markdown table in Sweave document

杀马特。学长 韩版系。学妹 提交于 2019-12-04 02:06:05
问题 I have a bunch of quite big tables in markdown that I created manually. I was using them in an Rmd document. Since I need more control with LaTeX and all, I am using a Rnw document. How can I put my markdown table in the Sweave file? Below a minimal example (not working): \documentclass{article} \begin{document} \SweaveOpts{concordance=TRUE} % my markdown table col1 | col2 | col3 ------|:---:|:---: row1 | cell1 | cell2 row2 | cell3 | cell4 row3 | cell5 | cell6 \end{document} I've tried to

Referencing a 'hand-made' table using bookdown package

为君一笑 提交于 2019-12-04 01:54:02
I am trying to reference a table using the bookdown package. In the documentation the author only shows how to create tables using knitr::kable . ```{r table1} knitr::kable( head(iris, 20), caption = 'Here is a nice table!', booktabs = TRUE ) ``` Table \@ref(tab:table1) is here. Using knitr::kable works just fine. The caption of the table is displayed and I can reference the table. I would like to do the same with a classic hand-made markdown table but obviously the code below fails. What can I do to get a similar result as with the code above? ```{r table2, echo=FALSE, results='asis'} cat('|

Adjusting sankey plot in tabbed section

最后都变了- 提交于 2019-12-04 01:43:42
In the r-markdown document given below, I use tabbed sections to display sankey plots. However, when a sankey plot is in a tab other than the first, adjusting (using htmlwidgets::onRender function) does not work. Does anybody know a way to overcome that problem? Related question: How to control node labels in Sankey diagram --- title: "Untitled" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) library(networkD3) library(htmlwidgets) nodes <- data.frame('name' = c('Node0','Node1','Node2','Node3','Node4','Node5','Node6', 'Node7','Node8','Node9','Node10',

Embed Rmarkdown with Rmarkdown, without knitr evaluation

这一生的挚爱 提交于 2019-12-04 01:35:41
I want to demonstrate how to write RMarkdown, where said RMarkdown demonstration is embedded within an RMarkdown document used to create the course material. Within this fenced code block, I don't want knitr to execute the chunk. I want to put something like this into my "top level" Rmarkdown document, and have everything that's between the outer fences be printed verbatim in fixed width in the output HTML document, rather than having knitr evaluate the inner embedded R code chunk and inline code. ``` --- title: "RMarkdown teaching demo" author: "whoever" --- # Major heading Here's some text

Rmarkdown - Run code and display errors in document

本小妞迷上赌 提交于 2019-12-04 01:15:37
I get an error message when running the code below which is expected - I would like this to be ran and displayed in the pdf, however the error is returned in r and the code doesn't run. {r, warning=TRUE} library(survey) debug(withReplicates.svyrep.design) I have tried warning=TRUE but this doesn't work. How can I get the error displayed in the document? Add error=TRUE to the chunk options. That will result in the script running to completion with the error appearing in the output. 来源: https://stackoverflow.com/questions/34137797/rmarkdown-run-code-and-display-errors-in-document

RStudio knitr themes

牧云@^-^@ 提交于 2019-12-04 00:43:10
I've just started playing with some of the new knitr features in RStudio. I've tried selecting several of the different themes in the R Markdown settings dialogue but these don't seem to have any noticeable impact on the style of my resulting document. Should it, or am I missing something? Everything just seems to come out in the default style no matter what theme I select. --- output: html_document: number_sections: yes theme: spacelab toc: yes pdf_document: default word_document: default --- Installation details: R version 3.1.1 RStudio Version 0.98.977 knitr 1.6 rmarkdown 0.2.50 htmltools 0

Include code from an external R script, run in, display both code and output

帅比萌擦擦* 提交于 2019-12-04 00:26:06
Is it possible to include code from an external R script in an .Rmd and simultaneously run the code, display the code, and display its results in the output .HTML file? For example, if I have x <- 1 y <- 3 z <- x + y z in external.R . In the output document I want to see the code above along with the result of z , i.e. 4. Essentially, I want the equivalent of what would happen if I copy/pasted what's above in an R chunk. So I want ```{r} some.library::some.function("external.R") ``` to be the equivalent of ```{r} x <- 1 y <- 3 z <- x + y z ``` In the output HTML file. I've tried things like

How to wrap code and the output in markdown (.Rmd)

瘦欲@ 提交于 2019-12-04 00:25:09
In my documents in r parts I use long codes like: ```{r} output <- "very long query for example url to some website............................................." output ``` Is there any way not to make R wrap the code automatically, let's say after 60 characters? I tried tidy=TRUE, tidy.opts=list(width.cutoff=60) option but it doesn't work. And I want the same with output, because the output of my query is some text. I want to display the whole content in many lines, not just the begining in one line. How can I do it? Things have changed since 2015, but FWIW given that you are now using