r-markdown

RMarkdown: UTF-8 works with Knit button but not with render()

我的梦境 提交于 2019-12-10 17:29:09
问题 I'm working in RMarkdown, trying to render a document that has some UTF-8 characters in it. When I push the "Knit" button in RStudio, everything works great. But when I use the render() function, the UTF-8 gets lost. Here's a short snippet of reproducible code: --- output: html_document --- Total nitrogen (µg/L) Water temperature (°C) Pushing the Knit button gives me the correct output, whether I view it in RStudio or in Chrome. But if I render the file with render(), I get: Total nitrogen

How to wrap text around plots in R Markdown?

扶醉桌前 提交于 2019-12-10 17:23:36
问题 Currently the default for R Markdown in R is to have one line of text in line with the plot but this looks very awkward and I would like to save space by having the text wrap around the plot (plot aligned left, with text wrapping on the right). 来源: https://stackoverflow.com/questions/40652012/how-to-wrap-text-around-plots-in-r-markdown

Is there a way to include child Rmd files from a different directory

拥有回忆 提交于 2019-12-10 16:34:31
问题 I have a master markdown file, e.g., Parent.Rmd, and a number of child documents being included with: ```{r child="introduction.Rmd", echo=FALSE} ``` ```{r child="chapter2.Rmd", echo=FALSE} ``` It seems that I should be able to do: ```{r child="Rmd/introduction.Rmd", echo=FALSE} ``` to pull the same file from a sub directory named 'Rmd' but knitr can't open the connection. I've also tried to use: `knitr::opts_chunk$set(child.path='Rmd')` but the chunk code ignores it. Is there another way? My

How can I auto-number math equations in RMarkdown?

天大地大妈咪最大 提交于 2019-12-10 15:57:26
问题 $$ r = \frac{1}{n-1} \sum_{i=1}^{n} \frac{(X_i - \bar{X})(Y_i - \bar{Y})}{S_xS_y} $$ The rendered equation is not numbered. Using \begin{aligned} and \end{aligned} generates an error. I am also using knitr in RStudio, knitting to PDF using pandoc and xelatex engine. Thank you. 回答1: Try align not aligned \begin{align} r = \frac{1}{n-1} \sum_{i=1}^{n} \frac{(X_i - \bar{X})(Y_i - \bar{Y})}{S_xS_y} \end{align} 回答2: As pointed out amsmath is already in the default template, so you can invoke the

add caption to flextable in docx

牧云@^-^@ 提交于 2019-12-10 15:37:11
问题 How could one add a caption to a flextable rendered to docx? EDIT: The aim is to produce a proper caption which can be referenced within the document to produce a list of tables and inline references. iris.t <- iris[1:5,] %>% regulartable() %>% style(pr_c = officer::fp_cell(vertical.align = "bottom", border.bottom = officer::fp_border(width = 2)), part = "header") %>% rotate(j = names(iris)[-c(1:2)], rotation = "tbrl", part = "header", align = "bottom") %>% height(height = max(dim_pretty(.,

knitr: Knitting separate Rnw documents within an Rmd document

橙三吉。 提交于 2019-12-10 14:49:22
问题 I have a master R markdown document (Rmd) within which I would like to knit several separate Rnw documents (NO child documents) in one of the chunks. However, when I call knit on the Rnw document, the contained R code chunks do not seem to be processed, resulting in an error when trying to run texi2pdf on them. Illustration of the situation: Inside master. Rmd : ```{r my_chunk, echo=FALSE, message=FALSE, results='asis'} ... some code ... knit("sub.**Rnw**", output = ..., quiet = TRUE) tools:

Is there an easy way to run bash scripts on R Markdown, using Windows 10?

扶醉桌前 提交于 2019-12-10 14:47:35
问题 I've been learning R Markdown for the past months. It was fairly easy to get Anaconda Python to run within a R Markdown script, but I haven't yet found a way to get to run chunks of bash code within the same document. Using ```{bash} echo hello world ``` I get the error message /bin/bash: C:\Users\MyName\AppData\Local\Temp\Rtmp0MpNfS\chunk-code-4cbc213a3545.txt: No such file or directory Might any of you guys know what might be the root of this problem? 来源: https://stackoverflow.com/questions

Font size in ioslides markdown presentation title page

…衆ロ難τιáo~ 提交于 2019-12-10 14:46:29
问题 Trying to alter the default text size of the title page from an ioslides presentation but failing: --- title: "My title is a bit too long to fully fit on the title page. I would really like to alter the font size to provide a better fit. I have limited CSS skills to do so" author: "My Name" date: "29 March 2016" output: ioslides_presentation: css: slide.css --- ## R Markdown This is an R Markdown presentation. Where my style.css file is: h1 { font-size: 12px;} 回答1: First, spacing/indentation

r knit word document plots automatically re-sized

…衆ロ難τιáo~ 提交于 2019-12-10 14:33:59
问题 I am trying to add a plot to a word document. I would like the plot to maximize the area available when the page size is set to legal with narrow margins. I can set the fig.width and fig.height but it seems the plots get automatically re-sized to fit the default page size (letter) with normal margins. Here is a sample .rmd file that produces the same results: --- title: "plot-resize" output: word_document --- Plot with the height set to 3" and the width to 7.5": ```{r, echo = FALSE, fig

How to use serverside processing in DT::datatable?

懵懂的女人 提交于 2019-12-10 14:23:31
问题 I am using DT::datatable() to visualize tables in a R markdown file. # R markdown file library(DT) ```{r viewdata} # this is an example but my actual dataset has 10000 rows and 100 columns var.df <- data.frame(x = rnorm(1:10000), y = rnorm(1:10000),...) DT::datatable(data = var.df) ``` When I run this code, I get a warning and the resulting HTML is very slow to load: DT::datatable(var.df) Warning message: In instance$preRenderHook(instance) : It seems your data is too big for client-side