knitr

How to add multiple figures across multiple pages in a chunk using knitr and RMarkdown?

[亡魂溺海] 提交于 2019-12-03 11:25:37
I am using a for loop to create multiple big figures across multiple pages in one chunk with knitr and rmarkdown. It works fine for word and html outputs, but has one problem in pdf output. This is a minimal RMarkdown example to reproduce my problem. --- title: "Knitr test" date: "6 April 2015" output: pdf_document --- ```{r, echo=FALSE, fig.width=6.5,fig.height=10} library(ggplot2) for (i in seq(1, 4)){ p <- ggplot(cars, aes(speed, dist)) + geom_point() print(p) } ``` The generated pdf file looks like this. Two figures are printed in the page. If I change the fig.height, add a few section in

Package inputenc Error: Unicode char \u8 in RStudio

青春壹個敷衍的年華 提交于 2019-12-03 11:06:55
问题 In RStudio, when i go for convert my Markdown file to PDF then it gives me the error: output file: report.knit.md ! Package inputenc Error: Unicode char \u8: not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H for immediate help. ... l.117 performance for 32 automobiles (1973â Try running pandoc with --latex-engine=xelatex. pandoc.exe: Error producing PDF from TeX source Error: pandoc document conversion failed with error 43 In addition: Warning

Is it possible to have sortable (Interactive) table in rMarkdown?

浪子不回头ぞ 提交于 2019-12-03 11:06:00
问题 I am using kable() from knitr package to show a table on a html document. Is it possible to make it sortable? Some sample code, --- title: "Test" output: html_document --- ```{r, echo=FALSE, comment=""} kable(data.frame("a"=1:10,"b"=11:20),digits=2) ``` 回答1: The package DT (https://github.com/rstudio/DT) is an R interface to the JavaScript library DataTables. You can use it in R Markdown, e.g. ```{r} DT::datatable(iris) ``` 来源: https://stackoverflow.com/questions/27120002/is-it-possible-to

How can I remove the prefix (index indicator) [1] in knitr output?

感情迁移 提交于 2019-12-03 11:02:34
Standard R output looks like this > 3 [1] 3 To remove the prefix 1 you can use > cat(3) 3 Is there a way to remove this globally? Or do you have to wrap cat() around everything? Further to that, I'm using this within knitr, so if there isn't an R global setting, there may be a knitr wide setting, I did look, but couldn't see one. Edit: It was asked why one would want this, something like if you wanted to structure a report like the below. The [1] is just not needed and means nothing to none R users (aka, the audience). Additional Info: In knitr you can use \Sexpr{} or r ... to evaluate

stargazer left align LaTeX table columns

女生的网名这么多〃 提交于 2019-12-03 10:47:21
stargazer automatically centres values within tables. How can I left align the columns? Put this code in an .Rnw file and use knitr to convert to .tex: <<load, echo=FALSE, warning=FALSE, message=FALSE>>= opts_chunk$set(eval=TRUE, echo=FALSE, warning=FALSE, message=FALSE, dpi=300) @ \documentclass[a4paper,11pt]{article} \usepackage{lipsum} % Required to insert dummy text \begin{document} \title{} \author{} \date{\today} \maketitle \section{Header} Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,

knit DT::datatable without pandoc

天涯浪子 提交于 2019-12-03 10:36:18
I am trying to use DT::datatable to output a nicely formatted, interactive table in R. ...only problem is that I want a heroku job to knit the document for me, and I've learned that RStudio and rmarkdown::render() use pandoc under the hood -- but pandoc doesn't ship in the stripped down R Buildpack for heroku. Is there any way to get the old markdown engine ( knitr:knit2html or markdown:markdownToHTML ) to pass the javascript that powers datatable through? Or to be more precise, to generate the sample table below without using pandoc? Here is a minimal example: testing.Rmd --- title: "testing"

How to remove white space above and below image in R Markdown?

余生颓废 提交于 2019-12-03 10:32:48
I want to export a .Rmd file primarily as a latex pdf. This is the code that I'm currently using ```{r ,fig.cap="caption",fig.env='figure', fig.width=10, fig.height=10,echo=FALSE, results='asis', warning=FALSE, strip.white=TRUE} library(png) library(grid) img <- readPNG("filepath/overview.png") grid.raster(img) ``` As you can see, I'm already using strip.white=TRUE & fig.env='figure' but they don't seem to work. The .PNG file hasn't got any (white) spacing above or below the image. I know I can use latex directly and achieve what I want, but I want to able to reproduce this in Word if needed.

knitr/Rmd: page break after n lines/n distance

梦想的初衷 提交于 2019-12-03 10:22:27
问题 Let me caveat by saying that this may be better suited as an html/css question but (a) I'm not too familiar with those techniques and (b) I wanted to keep it all in the family (R family) if possible. I would like to use knitr to write academic style reports ( APA 6 type guidelines ) using Rmarkdown. I've got most aspects worked out but not page breaking. I can manually set page breaks with something like: # report ```{r setup, include=FALSE} # set global chunk options opts_chunk$set(cache

Why Pandoc does not retrieve the image file?

久未见 提交于 2019-12-03 10:12:34
问题 On RStudio version 0.98.501 I had a long .Rmd file which was easily converted to html once I clicked KnitHtml button. The Knitting process, as I understand, created several folders including images (some manually added by myself), figures, cache and a knitHtml folder which included final .html file. I recently downloaded RStudio version 0.98.894 (preview release) because I wanted to use more features. Now, when I click knitHtml I get following error: pandoc.exe: Failed to retrieve C:/Users

Plots in beamer slides converted from .md by pandoc are extremely large

二次信任 提交于 2019-12-03 09:30:16
问题 Normal plots generated by R chunks in R markdown files are exactly there when converted to html slides or pdf. However, when they are converted to beamer slides by pandoc -t beamer ex.md -V theme:Warsaw -o beamer.pdf , the plots become extremely large, especially for those generated by par(mfrow=c(n,m)) , in which case only a little part of the plot is displayed. I tried to fix by setting the chunk option dev='pdf' , but it doesn't work out. The plot in html is The plot in beamer is 回答1: The