R is an open source programming language and software environment for statistical computing and graphics. It is an implementation of the S programming language combined with lexical scoping semantics inspired by Scheme.

learn more… | top users | synonyms

90
votes
14answers
23k views

Workflow for converting LaTeX into Open Office / MS Word Format

I often have to write up reports based on the analysis of some data. I use R to analyse the data and export tables, figures, and text. This is then included into a LaTeX document either using input or ...
52
votes
7answers
21k views

How to draw Venn diagrams (especially: complements) in LaTeX

What I am up to is to write some exercises dealing with logical formulas for my students, like: And the students should draw these formulas on Venn diagrams. At the end of the lesson, I really ...
20
votes
1answer
8k views

Getting Sweave code chunks to stay inside page margins?

Sometimes I get to make an R code chunk (in Sweave) which is longer then the margins of the page. Is there a way to force it to "go to the next line" once that happens? Here is a simple example of ...
19
votes
2answers
6k views

How can I use a table generated by R in LaTeX?

I have a LaTeX table generated like this, \begin{table}[ht] \begin{center} \begin{tabular}{rrrrrrr} \hline & 1 & 2 & 3 & 4 & 5 & 6 \\ \hline 1 & 181.21 & 169.01 ...
18
votes
2answers
1k views

Repeated slides in beamer

I have about 200 JPEG files that I need to include in a PDF document, one JPEG per page (i.e. 200 pages + intro slide). The following code successfully does this with one JPEG. ...
15
votes
3answers
3k views

Filling a full beamer slide with tikzDevice output from R

Q: What's the best way to fill an entire beamer slide with tikzDevice output (i.e., the .tex file output from the tikz() function in R's tikzDevice package)? I've included some undesirable examples ...
14
votes
2answers
5k views

How can I tell LaTeX that an \input file is in a different encoding from inputenc?

I'm currently writing a .tex report with my wife. She's on a Windows machine and I'm running Linux over here; we've decided to encode our report in ISO-8859-1 (i.e., we use ...
13
votes
3answers
7k views

Using fancyhdr to create an image based header and footer

I'm trying to generate a latex report (via Sweave and R) where the header of the document is an image that covers everything (including the top/left/right page margin) and the footer covers everything ...
12
votes
2answers
375 views

TikZ: Regression Line with Residuals

Desired Output I made this diagram in R with ggplot2. Now I want to reproduce this diagram with Tikz. My MWE is: \documentclass[tikz]{standalone} \usepackage{pgfplots} \usepackage{pgfplotstable} ...
12
votes
2answers
4k views

Tables with multiple panels in LaTeX, R and Sweave

I would like to know what the accepted Sweave/R/LaTeX solution is for producing tables with "panels": multiple parts, which may or may not contain the same columns, combined into one table. The ...
10
votes
2answers
1k views

How to Insert into Latex a Text File whose name is a variable?

I need to insert a text file into LaTeX. But text file names are different for different projects. So I want to define text file name as a variable and refer to the variable when inserting the text I ...
9
votes
3answers
1k views

Include Sweave input as verbatim

How do I keep Sweave from compiling things in a verbatim environment? For example: \documentclass{article} \begin{document} \begin{verbatim} <<>>= 1+1 @ \end{verbatim} \end{document} ...
9
votes
4answers
2k 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 ...
9
votes
2answers
961 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 ...
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 ...
8
votes
3answers
3k views

LaTeX techniques and templates for writing a book [closed]

I am about to write a couple of books using LaTeX. I am fairly used to producing small LaTeX articles using Sweave and R, but I have never written a book using LaTeX and I am not conversant with the ...
8
votes
2answers
829 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 / ...
8
votes
2answers
2k views

R, Sweave, Hmisc: pretty-print numbers

I'm creating a LaTeX tables based on a matrix in R using the 'latex' function of the Hmisc package. dat = matrix(c(1000, 100, 10000, 10000), 2) latex(dat, file='') This works (as expected) ...
8
votes
1answer
910 views

Barchart with pgfplots with data from R

It took me a while to create a nice (... to some extent) bar chart with R which represents what I need. However I noticed it doesn't look very aesthetic in my Latex document. Sweave isn't a good ...
8
votes
1answer
425 views

Having trouble with pgfSweave and tikzDevice

On Ben Bolker's advice I started using pgfSweave and tikzDevice. I'm struggling with getting R graphs into LaTeX. This is my code for pgfSweave Rnw file: \documentclass{article} \usepackage{tikz} ...
8
votes
5answers
2k views

How to get correct dimensions for a ggplot2 plot in beamer

I have a beamer presentation made with Sweave that I'm preparing and was wanting to place some ggplot2 graphs in but the aspect ratio does not seem to come out correct. This is what is in my Rnw ...
8
votes
1answer
331 views

Inconsistent output for R language operators when using listings package

A referee noticed that the <<- (assignment to a global) and %*% (matrix mult.) operators in a code listing I used were wrong. I am using the standard listings package (version 1.4 dated ...
8
votes
1answer
859 views

Sweave generating invalid LaTeX

I've encountered a problem when I'm using Sweave to convert an .Rnw file into a .tex file. Sweave is replacing three options from hyperref's \hypersetup block with the value NA. This is the section ...
8
votes
2answers
942 views

Compiling latex directly from R

I want to find a programmatic way of converting a .tex latex document to pdf. What I usually do, and this works in most cases, is to use: tools::texi2dvi(latexfile, pdf = TRUE, clean = TRUE) ...
8
votes
2answers
232 views

What tools are there to make LaTeX more viable at work

I do data mining in R, Python and various object oriented languages. I like using LaTeX to present my results; either to myself (i.e. use them for result interpretation/analysis) or to send to ...
8
votes
1answer
312 views

proper tool for charts in tex

I have scanned data graphics in a large ms written in TeX (of course). For copyright reasons I need to redraw these. My publisher may (sadly) decide not to use my source directly, so will need access ...
8
votes
1answer
1k views

Automating Adding Tables Fast to LateX from R? [duplicate]

Possible Duplicate: How can I use a table generated by R in LaTeX? I use a lot of tables from R, and I find it cumbersome and very slow to type the "&" and "\" etc. to get the tables ...
7
votes
4answers
165 views

tikz has probably problems with czech babel when compiling .Rnw

Problem Tikz seems to have a problem with \usepackage[czech]{babel}. I had a moderately big .Rnw document written in czech with some plots via knitr chunks. When I set dev = 'tikz' the TeXmaker ...
7
votes
1answer
271 views

Is it possible to get Sweave/knitr in RStudio to output the .tex file without typesetting it?

I would like to know if it is possible to tell Sweave or knitr in RStudio to create the .tex file without trying to typeset it. I want to be able to run my .Rnw file and produce a .tex file which I ...
7
votes
1answer
1k 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 ...
7
votes
1answer
331 views

Best Practice for nice layout with tikzDevice

R+tikDevice+LaTex+knitr is (as I understand it) the most efficient way to get relly nice looking publications from R, with maximum layout-support from LaTeX. I'm using R+LaTex+knitr now, but would ...
6
votes
4answers
2k views

Multiple Tables Sweave/Latex

I am very new to LaTeX and Sweave but am excited that it may make my life much simpler when combined with R. What I am looking to do: Create multiple crosstabs, most likely in a loop. As a result, ...
6
votes
1answer
2k views

Sweave, Beamer and ggplot2

There's literally nothing on the internet showing how these work in conjunction with one another. I would really appreciate even the simplest example of a Rnw document that you would run with Sweave() ...
6
votes
6answers
2k views

How to comment in an R-chunk?

I'm quite new to both R and LaTeX, but I'm trying to work with both, using Sweave. I know you can comment in R using # and in LaTeX by using %. However, when I write a #comment in an R-chunk (between ...
6
votes
1answer
150 views

How can I delete non-letter keywords (such as '<-')?

I am using the package to try and format my R code, and I don't like some of the things that are being treated as keywords (for the coloring scheme). However, when I specify deletekeywords={*,<-} ...
6
votes
2answers
2k 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? ...
6
votes
1answer
2k views

side-by-side xtables in Sweave

I use xtable to manage my tables in Sweave like this <<label=tab1, echo = FALSE, results = tex>>= print(xtable(Table1)) @ <<label=tab2, echo = FALSE, results = tex>>= ...
6
votes
1answer
111 views

Allow [ characters in tables without entering math-mode (from R)

I have R code that produces latex code like: \begin{tabular}{D{.}{.}{7}D{.}{.}{7}} \toprule \multicolumn{1}{c}{x} & \multicolumn{1}{c}{y} \\ \midrule [1, 5) & 1 \\ [1, 5) & 2 \\ [5, 8) ...
6
votes
1answer
356 views

Package to create TikZ Figures from R

I am wondering if there is a recommended package in order to create TikZ figures in R. In the paste I have used Matlab2TikZ to create TikZ figures in MATLAB - and I was hoping that there would be ...
6
votes
0answers
268 views

Arguments of R Functions in Beamer with knitr

I'm using helpExtract.R function (can be obtained from here) to get arguments of R functions in Beamer with knitr. My (.Rnw) MWE is \documentclass{beamer} \usepackage{ragged2e} %new code ...
5
votes
2answers
2k views

Wider tables in LaTeX, which is the best solution?

Hi I have a LaTeX table code generated from R like the following \usepackage{rotating} ... \begin{sidewaystable} \begin{center} \small\addtolength{\tabcolsep}{-7pt} ...
5
votes
2answers
2k views

Forcing roman font in LaTeX

I am using a LaTeX template from my university to typeset my thesis. I am making references to R and I have defined a new command with: \newcommand{\R}{R} in order to get the roman "R". The ...
5
votes
3answers
357 views

import R data frame into org-mode table

I have an R script that generates a data frame, that I export to a CSV file. The data looks something like this: "","Variant","Xaxis","N","mean","sd","se" "1","line1",10,5,111.11,9.33,3.11 ...
5
votes
2answers
362 views

How to label a code section in Sweave

I'm new to sweave and was wondering what is the appropriate way to label a code section. For example, if I have: <<echo= true>>= x<-5 y<-x+5 @ How would I get it to put a either ...
5
votes
2answers
313 views

Plotting R boxplots with pgfplots

I use quite a number of boxplots in my writing, and have chosen pgfplots as my plotting solution for a number of reasons (one of which is the benefit of having the data to build the plot in the tex ...
5
votes
1answer
933 views

longtable misplaced noalign

Question Why am I getting multiple misplaced \noalign errors? Reproducible example \documentclass{scrartcl} \usepackage{longtable} \usepackage{booktabs} \begin{document} \section{Table test} ...
5
votes
1answer
363 views

Selectively suppress caption numbering when using xtable

I have a chunk of code which is producing table output using Xtable and I would like to suppress the table numbering. I know I can suppress numbering using \caption* outside of Xtable but I'm stumped ...
5
votes
1answer
235 views

Plot weighted frequency matrix

I wish to create this plot preferably in pgfplots or tikz. I have actually got a version plotted (with help from SO), but I have used R and exported the plot using tikzDevice. I can't post the ...
5
votes
1answer
482 views

How to input \Sexpr{ as verbatim in Sweave?

Building on my question here: Include Sweave input as verbatim Is there a way to include the term \Sexpr{ in the Sweave document as verbatim. For example, to write: R code can be evaluated inline ...
5
votes
2answers
481 views

Automating LaTeX tables with specifications from R

I have some latex tables generated from R-code, the sample latex table code is below \begin{table}[ht] \begin{center} \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c} \hline & 1 & 2 & 3 & ...