Questions tagged [r]

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.

Filter by
Sorted by
Tagged with
213 votes
27 answers
111k 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 ...
Jeromy Anglim's user avatar
111 votes
3 answers
184k views

How to include LaTeX package in R Markdown?

I am writing a report with Rmd in RStudio via knitr package. I want to write a indicator variable symbol in the report, like How do you get \mathbb{1} to work (characteristic function of a set)?. ...
Stella Hu's user avatar
  • 1,210
51 votes
3 answers
53k 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 &...
alex's user avatar
  • 595
43 votes
2 answers
48k views

Suppress library comments from output with knitr

I noticed that some library comment manage to pass through the knitr options, with R 3.0.1 and knitr 1.5 running on Mac OSX 10.8.5. The following MWE \documentclass{article} \begin{document} <&...
Francesco's user avatar
  • 4,524
30 votes
4 answers
3k views

Literate R Programming

I'd like to embed some R into a LaTeX document. After a bit of googling I found that Sweave and knitr allow you to do this. I compiled a simple example with Sweave and it works. I'd be much obliged ...
user avatar
30 votes
5 answers
12k views

Error: Font ts1-zi4r at 540 not found

I use MikTeX in order to compile pdf files when creating R packages. Today I found out that I run into the following error: * checking PDF version of manual ... WARNING LaTeX errors when creating PDF ...
Tal Galili's user avatar
  • 1,329
28 votes
2 answers
34k 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 ...
Tal Galili's user avatar
  • 1,329
26 votes
1 answer
15k 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 ...
ichbinallen's user avatar
25 votes
1 answer
89k views

Export tables from R to LaTeX [duplicate]

This is a very basic question but any answers would really help. My question is are there any package or install requirements for LaTeX in order to be able to export from R to LateX? I am asking ...
Henry Cann's user avatar
24 votes
7 answers
12k 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 ...
AnjaM's user avatar
  • 691
24 votes
1 answer
39k views

Knitr and rmarkdown will not add figure captions to the output

I am writing a report on Rmarkdown and knitr using RStudio, and cannot find a way to get figure captions on my document. My code for the chunk where I try to plot is like: ```{r fig1,fig.width=4,fig....
Kenji's user avatar
  • 607
22 votes
2 answers
4k 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. \documentclass{beamer}...
Chris's user avatar
  • 1,127
21 votes
2 answers
22k 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 \usepackage[latin1]{...
Waldir Leoncio's user avatar
21 votes
1 answer
6k 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 ...
Chris's user avatar
  • 1,127
20 votes
2 answers
39k views

Trying to include R Code with listings package

I was trying to include some R Code in a simple LaTeX document, but for some reason I could not do it. I put the R Code in the same directory (I also tried putting the full directory for my R Code) of ...
User1234's user avatar
  • 303
20 votes
2 answers
20k 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 ...
Matt's user avatar
  • 303
18 votes
3 answers
21k 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 ...
Brandon Bertelsen's user avatar
18 votes
2 answers
7k 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 ...
itpetersen's user avatar
17 votes
4 answers
29k views

Latex Error: 'Sweave.sty' not found?

I downloaded the most recent version of Miktex Basic Installer (2.9.5105). After following the Miktex's instructions, I began working through Nicola Satori's Sweave Tutorial. The R portion of ...
user avatar
17 votes
3 answers
8k views

Howto: Set up knitr (*.Rnw compilation) from in TexStudio

How do I set up TeXstudio to compile xxx.Rnw files? I am using the TeX-Editor TeXstudio 2.7, on Windows 7, and R 3.01 64-bit. I would like to write a xxx.Rnw-file in TeXstudio and then from ...
JBJ's user avatar
  • 495
17 votes
3 answers
14k views

Pandoc-generated PDF contains large images, how can I make them fit into the page?

I am using pandoc to generate pdf output out of my markdown code. So far, it works fine without any warning or error, except the fact that figures are large, so that some figures get cut and don't fit ...
Bob's user avatar
  • 213
17 votes
3 answers
6k 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 ...
lowndrul's user avatar
  • 5,233
16 votes
4 answers
22k views

Using LaTeX font in R (Computer Modern)

I am looking for at way to plot graphs in R, using LaTeX fonts. In the documentation for pdfFonts in R, it states that: There are also mappings for "ComputerModern", "ComputerModernItalic" and, ...
YnkDK's user avatar
  • 341
15 votes
2 answers
72k views

Insert R code in Latex

How can I define the color for the \listings package to display R code in Latex to get the result exactly like in the R Studio platform (example like in the figure)?
Duy's user avatar
  • 1,295
15 votes
4 answers
7k views

A program to export latex tables to excel/ods/csv?

I know there are tools to export excel tables to latex, but what about the other way around? I get a lot of latex tables from functions in R (e.g.: texreg) that aren't perfectly customizable via the ...
generic_user's user avatar
14 votes
3 answers
35k views

How do I indent text within a tabular environment?

I'm trying to create a table in r markdown where the age groups such as 0-20 and 21-55 are indented: \documentclass{article} \begin{document} \begin{tabular}{lccc} \toprule Factors & 2 & 2 &...
guest_123's user avatar
  • 143
13 votes
2 answers
18k 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} \...
penguinv22's user avatar
13 votes
1 answer
15k 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, tabular....
Noam Ross's user avatar
  • 131
12 votes
2 answers
41k views

align, aligned and R Markdown

I have been working in R Markdown, which supports LaTeX, including in display mode. I had the following snippet for displaying aligned equations $$ \begin{align} a_1 &= \beta_0 \\ b_1 &= \...
Harold Ship's user avatar
12 votes
2 answers
4k 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} \...
MYaseen208's user avatar
  • 8,515
12 votes
1 answer
2k 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={*,<-} ...
mlegge's user avatar
  • 223
12 votes
2 answers
2k 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 ...
Chris's user avatar
  • 1,127
12 votes
1 answer
6k views

How to keep ggplot font size constant when varying figure width

I have different figures across my document with different width. I set the the font size for all ggplots globally with theme_set(theme_bw() + theme(text=element_text(family="Palatino", size=20))) but ...
Francesco's user avatar
  • 4,524
11 votes
2 answers
3k views

Encrypt and decrypt parts of text in a LaTeX source file

Assume that you have some text in parts of your LaTeX document that you only want people with a password to see. A reason could e.g. be a case with an guiding answer. You want to make the case public ...
Relund's user avatar
  • 245
11 votes
1 answer
1k 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 ...
Kenji's user avatar
  • 607
10 votes
3 answers
70k 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 ...
Jen Bohold's user avatar
  • 1,449
10 votes
3 answers
1k views

New R Logo with Tikz

I want to make the following new R logo with tikz. My MWE with output is: \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[] \node[blue] at (0,0) {R}; \draw (0,0)...
MYaseen208's user avatar
  • 8,515
10 votes
2 answers
3k 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 ...
user avatar
10 votes
1 answer
14k views

Plots are not appearing in PDF after using Sweave

In general, Sweave is making great looking PDFs for me. However, when I plot a histogram, it is not appearing in my PDF. I have a bare bones Sweave document as follows. I can't seem to isolate ...
tumultous_rooster's user avatar
10 votes
5 answers
4k 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 file....
Andrew Redd's user avatar
10 votes
1 answer
342 views

How can I use Context and R together?

I am using conTeXt to create pdfs (I need to use Context rather than any other latex engine because I am using their tagging feature to create pdfs with tagged document trees). I would like to be ...
clairekelley's user avatar
10 votes
1 answer
299 views

How to incorporate a TEXMF tree managed by distro's package manager when using TeX Live from upstream on a GNU/Linux system?

I am using upstream's TeX Live on a GNU/Linux system with default paths except for the use of symbolic links to facilitate switching between different versions of TL. So, for example, TEXMFMAIN is /...
cfr's user avatar
  • 186k
10 votes
3 answers
462 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 ...
user2763361's user avatar
9 votes
3 answers
4k 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 ...
Soumendra's user avatar
  • 257
9 votes
2 answers
2k 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 / ...
Peater de Xel's user avatar
9 votes
2 answers
4k views

How do I add multiple conditions to \ifthenelse?

Thank you in advance for any help. How do I add multiple conditions to \ifthenelse? I want to be able to write: \ifthenelse{varType equals 'HS' and metric equals 'KPI1'} {do this} \ifthenelse{...
Pawel's user avatar
  • 203
9 votes
2 answers
4k 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) perfectly....
FloE's user avatar
  • 193
9 votes
3 answers
3k 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} ...
Sacha Epskamp's user avatar
9 votes
1 answer
5k views

Using biblatex with R Markdown

I am trying to compile a PDF Output with an R Markdown file and build my bibliography with the biblatex package and using R Studio. Here are my code/files in index.Rmd --- title: | Hello World! ...
Nicolás Sacco's user avatar
9 votes
1 answer
4k views

What are the key advantages of TeX over R Markdown? [closed]

I have recently discovered that you can write scientific and non-scientific documents (articles, books, thesis, pamphlets, etc) using R Markdown. There seem to have very nice features. Some examples: ...
luchonacho's user avatar
  • 3,782

1
2 3 4 5
12