knitr

r-markdown: German quotation marks

橙三吉。 提交于 2019-12-10 21:47:26
问题 I coudln't find out how to use the "lang: de" option (link) properly. That is, while tables are correctly named "Tabelle", the following settings: --- title: "German quotation marks" author: "will" date: "24 Jänner 2018" output: pdf_document --- "Das ist sehr schön", sagte sie. Produce this output: whereas the following is needed: 回答1: Following Tobi we can define language and use latex package csquotes . --- title: "German quotation marks" author: "will" date: "24 Jänner 2018" output: pdf

Cairo font size in Knitr

主宰稳场 提交于 2019-12-10 21:02:51
问题 This question was migrated from TeX - LaTeX Stack Exchange because it can be answered on Stack Overflow. Migrated 6 years ago . I am trying to set the font size in a Cairo device, but the pointsize argument seems to set the size of the points in the plot, and not the font size. I have this MWE: \documentclass{article} \begin{document} <<setup>>= library(maptools) data(meuse) coordinates(meuse) <- c("x", "y") proj4string(meuse) <- CRS("+init=epsg:28992") @ <<fig1, dev='cairo_pdf', dev.args

knitr changing my reverse assignment operator -> to <-

寵の児 提交于 2019-12-10 20:39:35
问题 I am having trouble when using "reverse" assignment operators (->) in a knitr .Rnw file. For example, I have the following simple .Rnw file \documentclass{article} \begin{document} <<test>>= options(tidy=FALSE, width=50) 1:5 -> a @ \end{document} When I use knitr to compile into a pdf, the operator -> has been reversed so the output actually has 1:5 <- a in it! how can I change this? 回答1: Make tidy=FALSE a knitr chunk option rather than an R option: \documentclass{article} \begin{document} <

Need the filename of the Rmd when knitr runs

浪尽此生 提交于 2019-12-10 20:34:05
问题 Recently I asked about having an r variable set to the name of an Rmd file when knitr runs. Need the filename of the Rnw when knitr runs in rStudio knitr:::.knitEnv$input.dir knitr:::knit_concord$get("infile") Is there a similar knitr::: object for the name of an Rmd file? 回答1: You can search through the parent.frames until you find the frame referring to where the body of the function knitr is being evaluated (and thus the input argument is defined. get(env = parent.frame(n = 8), 'input')

adding horizontal rule to html rmarkdown doc hides sections of text

戏子无情 提交于 2019-12-10 19:29:58
问题 I am making an Rmarkdown document that knits to an HTML page. Instead of separating some text sections with headers or bullets, I just want to draw horizontal lines between them. According to http://rmarkdown.rstudio.com/authoring_basics.html this would be called a "horizontal rule" and I can do that with three or more --- . However when I actually try to do this, various sections disappear from the html doc. Here is a very simple example of my code: --- title: "formatting issue" author: "rrr

Italicise text in latex figure caption produced by knitr

a 夏天 提交于 2019-12-10 18:56:13
问题 I'm trying to to italicise some text in a figure caption created by knitr. I have the code below in a .Rnw file and I'm converting it to a .tex file using knitr: <<plot_setosa, fig.cap="A plot of $\\textit{setosa}$">>= plot(iris[iris$Species == "setosa",]) @ How can I italicise setosa in the figure caption? 回答1: Try: <<plot_setosa, fig.cap="A plot of \\textit{setosa}">>= plot(iris[iris$Species == "setosa",]) @ No need for the $$ 来源: https://stackoverflow.com/questions/20956049/italicise-text

xtable caption alignment left aligned with table or centered (using knitr)

怎甘沉沦 提交于 2019-12-10 18:34:39
问题 I'd like to align an xtable figure caption left adjusted with the table, or if that doesn't work, at least centered, because I think it looks kind of stupid a small table being centered and the corresponding caption being left aligned. Also, left aligning both table and caption is not optimal. It should be possible using latex.environments = "left" , but I get an error message, just like in this post. I don't think the problem lies in the referencing, because I get the same error message with

How are output digits handled differently by KnitR in chunks and inline code?

∥☆過路亽.° 提交于 2019-12-10 18:26:05
问题 I am confused about how KnitR handles the digits of output differently in chunks and in inline code with \Sexpr{} . Generally, I want them to be handled the same. This should not pose any problem once I understand how to set the options for both types of output, which I have not found in the manual. Please see the MWE below. \documentclass[12pt, english, oneside]{amsart} \begin{document} <<>>= options(digits=2) pi @ \Sexpr{pi} \end{document} In case you don't feel like compiling this, the

r: dprint: size of image of table alteration

二次信任 提交于 2019-12-10 17:55:56
问题 I am using the dprint package with knitr , mainly so that I can highlight rows from a table, which I have got working, but the output image leaves a fairly large space for a footnote, and it is taking up unnecessary space. Is there away to get rid of it? Also since I am fairly new to dprint, if anybody has better ideas/suggestions as to how to highlight tables and make them look pretty without any footnotes... or ways to tidy up my code that would be great! An example of the Rmd file code is

dygraph in knitr not working

半世苍凉 提交于 2019-12-10 17:47:26
问题 When trying to Knit my dygraph in R using Knitr: library(dygraphs) dygraph(nhtemp, main = "New Haven Temperatures") %>% dyRangeSelector(dateWindow = c("1920-01-01", "1960-01-01")) I get the following error: ## Error in validateCssUnit(sizeInfo$width): "\maxwidth" is not a valid CSS unit (e.g., "100%", "400px", "auto") Could anyone assist with how I can possibly fix this or what it means? EDIT: Example code. \documentclass{article} \begin{document} <<include=FALSE>>= library(knitr) options