knitr

How to force Knitr to evaluate \Sexpr after all other code chunks

与世无争的帅哥 提交于 2019-12-23 10:20:26
问题 I am trying to write an abstract for a dynamic document, but my \Sexpr{} calls are not working. Essentially all I am trying to do is start the document off with an abstract that has p-values generated from \Sexpr{value} where value is determined "downstream" in the document. For example This works: \begin{document} <<foo>>= value = 10 @ Today I bought \Sexpr{value} Salamanders \end{document} This does not work (and what I am trying to accomplish) \begin{document} Today I bought \Sexpr{value}

Reduce spacing between columns in table created with kable(, format = 'markdown')

霸气de小男生 提交于 2019-12-23 10:16:26
问题 I try to create a table using the format "markdown" of the function kable() , but the spaces between the columns are so wide that the table extends over the page. Is there anyway to adjust the cell size so that a table in markdown format does not extend over the page? In latex format it stays within the page, but I do not want this format nor do I want html . I want the output file to be .pdf. I know that a similar question has been asked here, but my question is specific to the format

Reduce spacing between columns in table created with kable(, format = 'markdown')

我的未来我决定 提交于 2019-12-23 10:15:36
问题 I try to create a table using the format "markdown" of the function kable() , but the spaces between the columns are so wide that the table extends over the page. Is there anyway to adjust the cell size so that a table in markdown format does not extend over the page? In latex format it stays within the page, but I do not want this format nor do I want html . I want the output file to be .pdf. I know that a similar question has been asked here, but my question is specific to the format

R CMD build skips knitr/Rmd vignettes - “Output(s) listed in 'build/vignette.rds' but not in package”

て烟熏妆下的殇ゞ 提交于 2019-12-23 10:14:20
问题 I have built an rmarkdown tutorial for an R package, and would like to include the compiled file when the package is built. Though the file compiles happily (including when I use R CMD Sweave to do so), I don't seem to be able to include it in a binary. Specifically, when I run R CMD BUILD I get * checking for file ‘./DESCRIPTION’ ... OK [snip] * installing the package to build vignettes * creating vignettes ... OK * checking for empty or unneeded directories Removed empty directory ‘rentrez

opts_knit$set(root.dir = path) does not work after RStudio upgrade 1.0.44

自闭症网瘾萝莉.ら 提交于 2019-12-23 10:03:59
问题 I upgraded to RStudio 1.0.44 and it seems knitr::opts_knit$set(root.dir = path) where path is my directory is not working as before. It throws a message: The working directory was changed to /... inside a notebook chunk. The working directory will be reset when the chunk is finished running. Use the knitr root.dir option in the setup chunk to change the the working directory for notebook chunks. This message will now appear in every following command. Note that I am not knitting the rmd yet.

knitr hook to separate 000's, but not for years

不羁的心 提交于 2019-12-23 09:48:34
问题 I define a hook at the top of my rnw to separate '000s with commas: knit_hooks$set(inline = function(x) { prettyNum(x, big.mark=",") }) However, there are some numbers that I don't want to format like this, such as years. Is there a better way to write the hook, or a way to override the hook when I print \Sexpr{nocomma} in the example below? \documentclass{article} \begin{document} <<setup>>= library(knitr) options(scipen=999) # turn off scientific notation for numbers opts_chunk$set(echo

knitr and UTF8 encoding

江枫思渺然 提交于 2019-12-23 08:46:11
问题 A few days ago, I started writing on a german R-Script. Unfortunately, the following code chunk doesn't work when I knit() the document: @ <<>>= äö <- ordered(c(1,3,2,2)) @ Can anyone help me solve this problem? PS: I'm working with Linux. 回答1: Since you are using Linux, things should be easy. It is probably just a LaTeX problem; most importantly, did you specify the encoding of your document? e.g. \usepackage[utf8]{inputenc} . This works for me under Ubuntu. \documentclass[ngerman]{article}

knitr and UTF8 encoding

怎甘沉沦 提交于 2019-12-23 08:46:06
问题 A few days ago, I started writing on a german R-Script. Unfortunately, the following code chunk doesn't work when I knit() the document: @ <<>>= äö <- ordered(c(1,3,2,2)) @ Can anyone help me solve this problem? PS: I'm working with Linux. 回答1: Since you are using Linux, things should be easy. It is probably just a LaTeX problem; most importantly, did you specify the encoding of your document? e.g. \usepackage[utf8]{inputenc} . This works for me under Ubuntu. \documentclass[ngerman]{article}

How to solve the 'ymax not defined'?

旧巷老猫 提交于 2019-12-23 07:49:48
问题 I'm trying to create a geom_bar with: <<boring-plots, fig.width=5, fig.height=5, out.width='.45\\linewidth',fig.show='hold', echo=FALSE, warning=FALSE>>= ma_at_vs_t_duh + geom_bar(stat="bin", fill="white", colour="darkgreen", width=.4) + ggtitle("Anzahl MA nach Vertragsart, \nMandant 10 und 50") + theme(plot.title = element_text(lineheight=.6, face="bold")) + xlab("Vertragsart") + ylab("Anzahl MA") + theme(axis.title.x = element_text(vjust=0.5, size=14), axis.text.x=element_text(size=10)) +

rmarkdown vector graphics for knit word

僤鯓⒐⒋嵵緔 提交于 2019-12-23 07:49:34
问题 When using rmarkdown with knitr in Rstudio to knit a Microsoft Word document, the graphics generally look crappy because the usual vector graphics formats, such as PDF are not supported in Microsoft Word. Fortunately, the devEMF package in R generates the microsoft vector format EMF, and I almost have this working for my rmarkdown application. The problem is that my image is showing up way too small. How can I control the image size? I've tried the standard things below: --- title: "Plot size