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.
58
votes
11answers
9k 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 ...
43
votes
7answers
11k 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 ...
18
votes
2answers
625 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.
...
16
votes
2answers
3k 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 ...
12
votes
1answer
3k 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 ...
12
votes
3answers
2k 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 ...
10
votes
2answers
2k 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 ...
10
votes
2answers
634 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 ...
10
votes
2answers
2k 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 ...
9
votes
3answers
2k 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 ...
8
votes
3answers
2k views
LaTeX techniques and templates for writing a book
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
3answers
661 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}
...
8
votes
1answer
346 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
1answer
237 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
2answers
434 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
1answer
912 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
1answer
746 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
1answer
547 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 ...
7
votes
5answers
1k 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 ...
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
1k 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
2answers
177 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 / ...
6
votes
1answer
985 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
3answers
569 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 ...
5
votes
2answers
180 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?
...
5
votes
4answers
869 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 ...
5
votes
1answer
164 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
271 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
385 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 & ...
5
votes
1answer
166 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 ...
5
votes
1answer
185 views
How to randomize content with examdesign package using Sweave
Forgive me in advance if this is a dumb question, or too specific to one package. I've been using examdesign to randomize the order of questions, but I also want to randomly generate the content. I've ...
5
votes
1answer
253 views
Including path diagram in Sweave
I use the following code to do sem analysis and draw path diagram with sem R package.
library(sem)
R.DHP <- readMoments(diag=FALSE, names=c('ROccAsp', 'REdAsp', 'FOccAsp',
...
4
votes
1answer
108 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 ...
4
votes
2answers
387 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 ...
4
votes
2answers
790 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}
...
4
votes
2answers
1k 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) ...
4
votes
2answers
197 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 ...
4
votes
1answer
630 views
Making LaTeX documents with Hebrew? (in Sweave + RStudio)
I would like to write in Hebrew in an .Rnw file, and use it with RStudio.
Searching around, I found an example for using Hebrew in LaTeX in general:
Numbers, punctuation and parenthesis reversed in ...
4
votes
1answer
753 views
Difference between \Sexpr and <<>>=
I am new to sweave and learning a lot. For the most part \Sexpr works well for simple variables and also calling R functions.
But other times it will fail, I have found that I can get around this ...
4
votes
2answers
1k views
Integrate 'Sweave.sty' in the TeXLive 2010 search path (on Linux)
I'd like to add 'Sweave.sty' to my search-path, so that I don't need to copy 'Sweave.sty' to every Sweave-Document I create.
I've located 'Sweave.sty' in '/usr/share/R/share/texmf/tex/latex'. I tried ...
4
votes
1answer
137 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?
3
votes
3answers
135 views
How to include R output in LaTex? [duplicate]
I am not sure about how to include my r output in the best way in my latex document.
Currently I saved my R output (NOT R CODE!) into a txt file:
*---------------------------------*
* GARCH ...
3
votes
2answers
471 views
TikZ: Drawing the same data with scatter plots and parallel coordinates
I am new to TikZ and trying to recreate the following image (which was created in R):
(Translation: correlation = +1, correlation = -1, two clusters, circle, normal distribution)
Each "column" ...
3
votes
3answers
471 views
Table Limit: Sweave
I'm running into an issue. It seems that when I try to output more than 17 or 18 tables to a pdf document the remaining tables are ignored. When I split them across multiple Rnw files, there is no ...
3
votes
1answer
253 views
Using listings for R code with ## in rangeprefix
In R, comments are preceded by the symbol #. Moreover, to avoid messing with the indentation, it's usually ## instead of #. Therefore, as I want to include some R code in a LaTeX document, I am using ...
3
votes
1answer
307 views
Making a LaTeX text R logo. How maintain the proportions?
I tried to mimic the R logo in jpg format from R site only with LaTeX in order to make it scalable with the context without external files.
This is the result at tiny, normal and huge size, compared ...
3
votes
1answer
771 views
How to print a LaTeX matrix using xtable in R
I'm trying to get R to print a matrix as a LaTeX matrix using xtable, using the LaTeX environment bmatrix.
a <- matrix(rnorm(25), 5 ,5)
x <- xtable(x)
> print(x, floating=FALSE, ...
3
votes
1answer
82 views
How to control latex appendix environment when placing R code in?
I am having a problem with latex environment. When I place r code using \begin{lstlisting} ... code..\end{lstlisting} other objects like tables are displayed only after the script subsections, despite ...
3
votes
2answers
364 views
Undesired quotes around values in table (pgfplot)
I am saving tables using write.table in R using the following code:
x <- rnorm(100)
y <- rnorm(100)
z <- rnorm(100)
model <- z ~ x + y
results <- glm(model)
pe <- ...
3
votes
1answer
456 views
Latex listings R: need mono-spaced font with bold keywords and correct caret (^)
I am using the listings package to display R code. I would like a monospaced font, bold keywords, and I would like code that works when the user cuts and pastes from the pdf file into rstudio. The ...
