knitr is an R package for dynamic report generation based on the concept of literate programming.

learn more… | top users | synonyms

3
votes
1answer
230 views

addplot data frame

Square one: I have about 8 hours of experience. I want to make a barplot in pgfplots and see many great, creative solutions on this blog. All I want at this stage is not to specify coordinates and not ...
2
votes
1answer
138 views

Knitr plotting outside margin

I like the look of plots that extend beyond the margins \documentclass{article} \usepackage{lipsum} \usepackage[demo]{graphicx} \begin{document} \begin{figure} \centering ...
5
votes
1answer
453 views

How to build Knitr document from the command line

I would like to compile a knitr document from the command line. With Sweave, the sequence R CMD Sweave my_sweave_file.Rnw latex my_sweave_file.tex latex my_sweave_file.tex dvips my_sweave_file.dvi ...
6
votes
1answer
506 views

Building TeX file from knitr Rnw as child of larger parent TeX file to use R objects and output

Here's my general problem: I'm writing my dissertation using a LaTeX template (http://www.latextemplates.com/template/masters-doctoral-thesis). The template is a parent file with multiple chapters as ...
1
vote
0answers
81 views

Knitr/LaTeX: conditional execution based on external parameters

I'm using knitr to create LaTeX documents with integrated R code. Now I'd like to readout some external parameters (saved in a TXT or CSV file) and create a document based on the conditions specified ...
2
votes
1answer
207 views

xtable function generated latex does not get parsed for special char such as square brackets

I'm using the knitr package for putting my R output into PDF. I have two problems using xtable: When my table data has chars like this: [, ] in them, the conversion from .tex to .pdf fails with ...
3
votes
1answer
222 views

Is there a PythonTex equivalent to \Sexpr{} in R?

I started to use the excellent PythonTex package to write reproducible reports but can't seem to get it to evaluate Python code inside a LaTeX command. R has Sweave & knitr which provide the ...
3
votes
1answer
138 views

Robust processing of autogenerated LaTeX files that contain many errors

I use knitr to generate pretty reports, with pdflatex as backend. Everything works fine if the R code runs without error. However, if the R code fails, the autogenerated file is sometimes invalid in ...
1
vote
1answer
852 views

Plot two figures side by side in knitr without changing mfrow?

I would like to plot 2 figures side-by-side using knitr. I know I could use par(mfrow=c(1,2)), but I've done a lot of work making the figures just right as they are. I've seen this (Two column layout ...
2
votes
1answer
283 views

insert figure in sweave using knitr fig.path

I'm trying to insert a figure using Sweave which is located in the path C:\Users\eccehomo\Documents\mi\fig1.png. I'm using the package knitrwhich has a function called fig.pathbut I'm getting many ...
2
votes
1answer
99 views

How can I make German characters from \input file display correctly?

I'm working with a Rnw file in RStudio and knitr. Everything works correctly so far, but I stumbled upon a problem when I included a chapter to the report that is written in German. I wrote the ...
2
votes
1answer
318 views

Texstudio and Rnw Files

Is there any way in Texstudio, for the document tree to detect Rnw files called within a knitr chunk? For example, the following would be ignored: <<MYCHUNK,child='./Myfile.Rnw'>>= @ ...
5
votes
1answer
330 views

Beamer (with style) to Html5?

My organization require the use of a standardized powerpoint template for how slides should look, so I've written my own Beamer .sty (style file). Then I write .Rnw-files in RStudio that I knit ...
5
votes
2answers
144 views

Create pdf with subset of slides

I use knitr and RStudio with XeLaTeX to create a presentation with many slides. But sometimes not all of the slides should appear in the final pdf. Is it possible to have a variable that I change ...
2
votes
1answer
102 views

Finding the current position on the PDF

I am trying to generate automated reports in R using knitr. There are a list of objects I need to print on the PDF and the size (rows, columns, length etc.) can vary. The problem is that when any of ...
3
votes
1answer
716 views

Using knitr, how can I rotate page to landscape and fit the figure to full extent?

LaTeX newbie here, so please be gentle. I'm working with knitr to generate pdf report. The document consists of quite few large maps, with a lot of details or small multiples. Ideally, whenever such ...
4
votes
1answer
328 views

Using Greek letters in LaTeX tables

I have the following Rnw document which I intend should produce a small table with "a b c" and "α β γ". At the moment, the encoding seems to be causing problems. The funny thing is that the output in ...
3
votes
1answer
211 views

Math mode in knitr

How do one use a math-mode in knitr? For example as a label for X-Y axis: <<fe, echo=FALSE, sanitize=TRUE, dev="tikz">>= plot(1:10, main="${}^{57}Fe$", xlab="$\\\\lambda$", ...
4
votes
1answer
704 views

knitr problem after update to R 3.0.0

I just updated R to 3.0.0. I couldn't compile PDF from my .Rnw file, which I could do with R 2.15. Here is the error I got: ! Undefined control sequence. l.192 \SweaveOpts ...
3
votes
1answer
133 views

Knitr and tikzDevice not working together with article options

I have a problem with knitr and tikzDevice, like someone before me. (See tikzDevice is not getting sizes right (knitr) .) He used dev.args to get rid of this error, but if I run this code through ...
7
votes
2answers
663 views

tikzDevice is not getting sizes right (knitr)

I am using OSX, pdflatex, R (cran), tikz/tikzDevice and knitr to create my documents. My problem is that the font sizes of the produced tikZ-file do not match the LaTeX document font sizes. Result / ...
2
votes
0answers
103 views

Long and rescaled xtable [duplicate]

Is there a way to use scalebox along with tabular.environment='longtable' when printing a long and wide xtable? When I give both of them I get an error: Running xelatex.exe on my_file.tex...failed
1
vote
1answer
791 views

knitr how to label and call a figure number in a text

As a knitr beginner I don't know how to label a figure and call it. For my first figure I've tried the following code witouth succes... <<fig.cap="Dendrogram of GDP ...
6
votes
2answers
1k views

R-code linebreaks AND code highlighting in knitr

I used the great answer from @Sharpie on 19 Jan 2012 Getting Sweave code chunks to stay inside page margins? to get linebreaks in the R-code, but how can there be code highlighting (colors) too? ...
3
votes
2answers
183 views

Force paragraph to stay with previous

I am using knitr to create inline sparkline-esque graphics. However, when knitr inserts images that it generates with R, it add a blank line, which forces LaTeX to make a new paragraph. That is, if I ...
1
vote
0answers
177 views

knitr : Figure are not appearing at the correct place [duplicate]

I'm trying to use knitr while learning LaTeX but all my figures are placed at a seemingly random place. It's driving me insane. Any ideas? Example Input PDF Output I tried reinstalling TeX Live ...
2
votes
0answers
102 views

Highlight R chunks in a Knitr document when working in Kile

When working on a knitr document in kile I can get highlights for the LaTeX parts of the document by adding the *.Rnw file extension in the Modes & Filetypes tab under Open/save configuration ...
3
votes
0answers
208 views

Show knitr-RNW document structure in Kile

When working with a knitr file (RNW document) on Kile the document structure isn't shown in the structure view, even though it contains a valid LaTeX structure of parts, sections etc. If I change the ...
3
votes
1answer
242 views

knit with `pdflatex --shell-escape myfile.tex`?

I want to insert a word count into my .Rnw file. To do this, I have the following line in myfile.Rnw: \makeatletter\@@input|"echo `texcount -1 myfile.tex`| cut -c1-4"\makeatother But this requires ...
2
votes
1answer
242 views

How to remove the blank page when omitting comments and messages in knitr

I am using the following code to create a plot, I want to omit message, comments and warnings and everything else but the plot. \documentclass{article} \usepackage{pdflscape} \pagestyle{empty} ...
3
votes
1answer
344 views

How use LaTeX counters to label knitr code chunks?

Imagine one has the LaTeX environments Example and Solution defined from the theorem environment. I have several Examples in numerous child documents which make up a book. LaTeX will automagically ...
6
votes
2answers
2k views

Vertical aligning text and vertical height of rows in longtable environment

I have now been working on fixing this problem for some time and I have read through some forums on the Internet and tried different things, but I can't solve this problem. I am looking to have some ...
3
votes
1answer
171 views

Setting Knitr options

The following code chunk doesn't work I get an error message and it disrupts the compilation of my document. Not sure if anyone has any ideas? Very M WE below. As @Speravir pointed out, not sure it ...
2
votes
1answer
713 views

knitr with TeXworks

There is a great piece on Yihui's site about using knitr with TeXShop. Taking some time for some self indulgent curiosity here. Is there a way to use knitr as an engine in TeXworks?
4
votes
1answer
149 views

Pgfplotstable converting zeros to — in a knitr inline table

how do I change each 0.0 to -- without having to reference each as string type or making the whole table string type? The actual table is quite long and it would take too long to do it manually. For ...
10
votes
1answer
870 views

Two column layout with text and knitr chunk

When making presentations (with latex beamer class), I often go for a frame layout with text and equations on the left and a corresponding figure on the right. My standard solution has been to wrap ...
2
votes
1answer
306 views

Adding a knitr table from R into a \pgfplotstableread statement

I'm trying to get a table from R into a pgfplotstable to edit for printing. the r code is \documentclass{article} \usepackage{pgfplotstable} \begin{document} \pgfplotstableread[format=inline,row ...
4
votes
1answer
224 views

Align Numeric Values from knitr command \Sexpr{} by Decimal in Table

How can I align numeric values brought in from the knitr command \Sexpr{} by decimal in a table?
2
votes
1answer
464 views

Program Tikz in Beamer

The attached .Rnw-code produces two similar slides, but with different texts and different arrow positions. I wrote both slides manually, but because I need to produce hundreds of similar slides, I ...
1
vote
0answers
289 views

LaTeX figure cross reference label using RStudio and knitr [duplicate]

Possible Duplicate: Why does an environment’s label have to appear after the caption? Where to put the \label on a figure environment? When using RStudio to write a .Rnw file, I find that ...
1
vote
1answer
706 views

Sweave and Matrix

I am using xtable to generate Matrices x1mean <- matrix(c(204.5, 556.5), 2) x2mean <- matrix(c(130.0, 355.0), 2) x1mmat <- xtable(x1mean, align = rep( "", ncol(x1mean) + 1) ) x2mmat <- ...
7
votes
4answers
1k views

knitr and biblatex

I'd like to create a PDF report with knitr with LaTeX-code in RStudio with biblatex for citations. However, the in-text-citations are always undefined and no bibliography is printed. The same ...
8
votes
1answer
969 views

Command already defined

I came across an odd problem compiling LaTeX exam.cls document producing with knitr. Pasted below is minimal reproducible code. knitr compiles fine, but pdflatex terminated with: Command \framed ...
0
votes
1answer
124 views

Question mark in knitr code getting quote marks [closed]

I'm trying to use question marks in a code block using knitr, but in the compiled pdf always puts quotes around it, so, for example <<helpCode, eval=FALSE>>= ?rnorm @ comes out as ...
0
votes
1answer
684 views

Looping a code-chunk in LaTeX

I want to generate a report for three types of analysis I am performing. But each time when I perform the analysis it can happen that one or more than one type of analysis occur. I want to put ...
9
votes
1answer
1k views

R+LaTex to HTML5 better than pdf?

I use R together with ggmap, ggplot2, Rstudio, knitr, and beamer to produce presentations in pdf. Soon I hope to have time to learn TikZ too. I have not moved to Markdown because I appreciate the ...
2
votes
1answer
217 views

Rstudio output in Hebrew

(Follow-up to Making LaTeX documents with Hebrew? (in Sweave + RStudio)) Trying to reproduce the above answer, I followed these instructions without success, under Windows 7. The best result I got ...
2
votes
1answer
321 views

Command that gobbles all following empty lines

One distinction between knitr and Sweave is that the former forcibly inserts two empty lines in the generated TeX source for chunks that do not do any output. I'm not sure if this issue is a bug or a ...
2
votes
1answer
366 views

How can I have subfloats with knitr in LyX?

I have two knitr chunks in LyX that work fine by themselves in their separate floats (this post applies to both figures and tables). But when I try to put them in as subfloats (by selecting both and ...
1
vote
1answer
276 views

How do I reference an object inline in LyX that is in a knitr chunk?

Suppose I have an object that was processed in an earlier knitr chunk, say my_df <- read.dta('somefile.dta') x <- mean(my_df$age) Putting an inline knitr chunk does not work -- the knitr ...