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
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
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
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
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
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
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
6 votes
2 answers
8k 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} \begin{tabular}{|c|c|c|c|...
alex's user avatar
  • 63
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
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
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
8 votes
1 answer
733 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 ...
Ethan Bolker's user avatar
  • 9,201
6 votes
2 answers
21k 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 ...
dynamo's user avatar
  • 243
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
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
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
5 votes
1 answer
3k 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 ...
Fran's user avatar
  • 77.5k
1 vote
1 answer
534 views

missing minus sign in R code using latex

I'm using lstlisting to include my R code in my LaTeX, however, the minus sign after < is not appearing in the compiled file. \usepackage{listings} \begin{document} \begin{lstlisting} [language=R]...
user85047's user avatar
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
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,305
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
9 votes
1 answer
26k views

What is the best way to include R code in the Latex paragraph

I am a newbie in Latex. I have two simple questions regarding including R code in Latex. Q1: For a block of R code, I use 'listings' package, as follows. \documentclass[12pt]{report} \usepackage{...
SixSigma's user avatar
  • 413
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
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
8 votes
1 answer
1k 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 ...
Alastair's user avatar
  • 433
5 votes
3 answers
8k views

Help with long table from Stargazer

I have a table made in R with Stargazer however, it is too big to fit a page in LyX. I have tried to use \longtable but it doesn't seem to work (might be doing it wrong). Here is the original code \...
user159718's user avatar
4 votes
2 answers
2k views

Fedora manual installation and dependencies

Following answers on this website (like: How to use TeX Live on Fedora 17? and Manually installed TexLive on Fedora 16 ) I installed texlive manually on fedora and it works flawlessly. The problem I ...
CarrKnight's user avatar
3 votes
1 answer
1k views

R listings operator partially in bold

I am using listings to display R code. The matrix multiplication operator shows up partially bold, something like this: "\%\textbf{*\%}". If I separate the * and the %, the second % is not in bold. I ...
Robert McDonald's user avatar
3 votes
5 answers
11k views

Export plots from R directly to Latex

Is there a way to export plots from R directly to latex, more specifically TexStudio? I think exporting/saving the image from R and then importing it to R looses some of the quality. I saw on the ...
Numbermind's user avatar
3 votes
1 answer
572 views

How can I get Rchunks to render inside tcolorbox?

I've created a reprex to show my problem, but I am having this same issue in a custom Rmd template I am crafting. I would like to be able to include stylized code chunks and plot outputs inside of ...
dylanjm's user avatar
  • 207
3 votes
1 answer
684 views

Problem in StatWeave

I visited http://www.stat.uiowa.edu/~rlenth/StatWeave/ and installed StatWeave according to the instructions. But my problem is that there are no Step by Step instructions given in the manual, and ...
Iftikhar's user avatar
  • 493
3 votes
1 answer
1k views

siunitx error: "invalid-number" from R

I have a document in .Rnw which I use to produce a .texdocument with kntir. I have a problem with the formula \num{\Sexpr{max(degree)}} which in R console produce 12598 but after the running knitr in ...
Francesco's user avatar
  • 4,524
2 votes
0 answers
7k views

Fatal error occurred, no output PDF file produced in php file [closed]

We are using following code in .php script for generate .pdf file. $result1 = exec("R CMD Sweave /var/www/html/r/r_latex_sweave.Rnw"); $result2 = exec("pdflatex /var/www/html/r/r_latex_sweave.tex"); ...
narola's user avatar
  • 21
1 vote
1 answer
784 views

R studio cannot make xtable

library(xtable) library(magrittr) library(moonBook) options(ztable.type="html") a=mytable(head(iris)) a x = xtable(a) x i cannot make xtable, just use mytable... want to use xtable, but output like ...
youngjae jung's user avatar
1 vote
1 answer
303 views

How to pass a variable from Rmd file to a latex file

I have two file 1. index.rmd file and the other is 2.Preamble.tex file I want to delclare a variable in index.rmd i.e. a <- 'Start and end with single quote' I want to pass the above variable in ...
SID's user avatar
  • 11
0 votes
1 answer
82 views

Several error in equation typing

This is my equation. \begin{equation} E$\epsilon$$\epsilon$=V$_$$\epsilon\$=$\Omega$ \end{equation} These are the errors that I'm receiving Dispaly math should end with $$ Missing $ inserted Missing {...
Alexa Thomas's user avatar
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
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
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
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
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
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
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
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