knitr

Missing text in PDF after R chunk in Lyx/knitr

折月煮酒 提交于 2019-12-08 06:21:12
问题 I'm using Lyx 2.1.2 with knitr on a Fedora 20 x86_64 system. I'm not sure how to determine the version of knitr, but it is certainly working, generally providing very good results. However I see two problems: (1) If I include the final @ in any of the chunks, it appears literally in the text. Naturally I don't mind if I don't have to add the final @. It's implied by the end of the chunk, anyway. However (2) if I do NOT include the final @ in Chunk 3 (see below), then all of the document text

Align panel.background instead of plot.background with document margins

泄露秘密 提交于 2019-12-08 05:26:26
问题 I would like to have plots generated by ggplot2 inserted into a LaTeX document with the panel as wide as \textwidth (or \columnwidth in a two column document). I have the following solution: \documentclass{article} \usepackage{lipsum, graphicx} <<knitrOpts, echo=FALSE>>= knitr::opts_chunk$set(echo = FALSE, fig.show = 'hide', fig.width=general_fig_width <- 5, fig.height=3, out.width = out_width <- "5in", out.height="3in" ) @ \usepackage{geometry} \setlength{\textwidth}{\Sexpr{out_width}} <

Reusing chunks in Knitr

[亡魂溺海] 提交于 2019-12-08 04:41:33
问题 I'm having lots of fun with Knitr but noticed I am reusing code in a bad way - cut and paste. In my example I want to load a dataset, calculate some statistics and print those, and plot the dataset -- easy to do with a few chunks, but if I want to do the same thing with another dataset I have to copy and paste the chunks and change only the name of the dataset. Suppose I have something like this : <p>Load the dataset <tt>dataset01</tt></p> <!--begin.rcode load-dataset01 # Create an alias so

knitr to produce pdf output file

孤街浪徒 提交于 2019-12-08 03:47:28
问题 I would like to be able to use knitr to produce a structured PDF file. I did not see anything unless the input file is Sweave format. This question may be too vague but I really like to know right from knitr , is it possible to create a structured PDF output file without using any Sweave or LaTeX ? 回答1: Try using command knit2pdf if you haven't already. 来源: https://stackoverflow.com/questions/14586177/knitr-to-produce-pdf-output-file

How to solve R Markdown (Knit) “'closure' is not subsettable”?

删除回忆录丶 提交于 2019-12-08 03:06:17
问题 I am trying to use RMarkdown (Knit) for the first time to produce pdf. The default file (File > New File > R Markdown) works well, it shows the generated pdf when compiled. For example, the following code runs, ```{r cars} summary(cars) ``` However, if I just change cars with "myData," it does not compile and shows, Error in object[[i]] : object of type 'closure' is not subsettable Calls: <Anonymous> ... withVisible -> eval -> eval -> summary -> summary.default Execution halted I have "myData

Saving graphs in both pdf and png format but using pdf files in the final document

不打扰是莪最后的温柔 提交于 2019-12-08 02:51:00
问题 I'm using knitr for my analysis. I can save graphs in pdf format with \SweaveOpts{dev=pdf} and in png format with \SweaveOpts{dev=png} . I'm interested to save graphs both in pdf and png format in one run but to use the pdf in the final documents interactively. Any suggestion will be highly appreciated. Thanks 回答1: Here comes the real solution: Knitr 0.3.9 starts to support multiple devices per chunk (for now, you have to install from GitHub); in your case, you can set the chunk option dev=c(

For Loop for Creating Multiple Tables using knitr and kableExtra packages in RMarkdown

不羁的心 提交于 2019-12-08 02:39:20
问题 I need to create multiple tables in RMarkdown and style it with the kableExtra package. As an example, I have the iris dataset. My first table displays the first 20 rows, my second table the next 20 rows, and my third table next 20 rows... Below is the code: --- title: "" output: pdf_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) ``` ```{r} library(knitr) library(kableExtra) landscape(kable_styling(kable(iris[1:20, ], format = "latex", align = "c", row.names =

Increasing the size of axis labels in KnitR with R Markdown

非 Y 不嫁゛ 提交于 2019-12-08 02:15:07
问题 In KnitR with R Markdown, I can use dev.args=list(pointsize=18) to pass the pointsize argument to the graphics device. That increases the size of the points in the plot, and also the amount of space around the plot, but it doesn't seem to affect the size of the axis labels. It seems like I need to use something like par(cex.axis=1.5, cex.lab=1.5) , too. Is that as expected? Here are three example code chunks with the images produced: First the defaults: ```{r fig1} x <- rnorm(100) y <- 2*x +

Issue creating model summary table using package texreg with RStudio/rmarkdown/knitr

和自甴很熟 提交于 2019-12-08 02:11:39
问题 I'm using the RStudio IDE (v 0.99.323) with rmarkdown and am attempting to produce model tables via knitr using htmlreg to produce MSWord output. Suspect I've missed something simple. The rmarkdown chunk appended below creates a separate word file 'mytable.doc' with a beautiful table. However, when I click 'Knit Word' in the RStudio IDE, the line htmlreg(m) generates html table code in the MSWord document. What am I doing wrong? Many thanks! --Dale ```{r, results='asis'} library(MASS) library

servr::jekyll() yields ready website, servr:rmdv2() does not

三世轮回 提交于 2019-12-08 01:24:19
问题 I'm basing my rmarkdown -Jekyll-Blog off of Yihui's fantastic boilerplate for using servr::jekyll(), which in turn wraps knitr . Because I want to use citations (via pandoc-citeproc , wrapped by rmarkdown ) I need to use rmarkdown::render , not knitr to, well, render the *.md s. As per the servr manual, I understand that rmdv2() should do the job, which essentially wraps/modifies jekyll() : The functions rmdv1() and rmdv2() are similar to jekyll(), and the only difference is the way to