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

1
vote
1answer
45 views

MikTeX won't let me install packages

I'm trying to learn how to use TeX within R. I've downloaded R, RStudio, and proTeXt. When I try to compile it, I receive a message that I am missing several packages; however, when I try to find a ...
29
votes
4answers
938 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 ...
2
votes
0answers
15 views

Font size of references list in Pandoc

I am using RMarkdown to make a document with references from a .bib file as shown below. How can change the font size and line spacing of the references list printed at the end of the page --- author:...
1
vote
0answers
18 views

xtable, via knitr, inside multicols

How can I put an xtable (made with knitr) in a multicols environment? The table is working outside multicols, but when I place it inside multicols it disappear. I've tried with lstlisting inside ...
3
votes
1answer
59 views

Conditional evaluation of Sweave chunk

I'm using some R code to import and manipulate a time series. The code takes some minutes to run and, as a result, it generates a relatively small time series. Now, to prevent typesetting to take an ...
3
votes
1answer
84 views

Fonts in latex and R [closed]

This question could be linked to this, this and this. However, I opened a new one because I tried two different options from the suggestions and getting different results. The aim is to get ...
6
votes
2answers
471 views

\mathplus fails to render

I'm new to LaTeX - can anyone suggest why the $\mathplus$ is not rendering as +? It can be seen in the bibliography entry of another question, publisher = {Springer Science $\mathplus$ Business ...
2
votes
1answer
29 views

listings with R: keywords in variable names are highlighted when using underscores?

When using language=R as a lstlistings style, if a variable name contains a keyword surrounded by underscores it will be highlighted. See the image and code example below. What can I do to prevent ...
2
votes
1answer
76 views

Tables with reference to R objects in sweave / latex

I'm using knitr/R-sweave to produce a pdf-document wit LaTeX-code. I want to make a table with some numbers produced by some R calculations in the R-code-chuck above this table. When I usually want to ...
1
vote
0answers
20 views

pdf error when compile a knitr figure chunk

I am getting !pdfTeX error: pdflatex (file D:/project/figure/plot-1.pdf): PD F inclusion: required page does not exist <0> ==> Fatal error occurred, no output PDF file produced! when ...
1
vote
0answers
18 views

Adjusting the text width of R listings in LaTex

Hi I have R codes that I am listing in my LaTex file with \begin{lstlisting}[language=R] R code \end{lstlisting} I have no specific listing setting in my preamble. My R code is very wide and ...
3
votes
0answers
47 views

glossaries with tikzDevice

I am using tikzDevice to run my R-scripts within latex. This is my code -- \documentclass{article} \usepackage[acronym]{glossaries} \usepackage{tikz} \makeglossaries \newacronym{gcd}{GCD}{...
2
votes
1answer
15 views

Knitr/Sweave Format Code Output w/ Leading Characters

Using knitr/sweave, I need to format the R code output that gets echoed, according to editorial journal requirements. For example, the following chunk <<example,echo=TRUE>>= library(plyr)...
11
votes
2answers
2k 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 ...
3
votes
1answer
61 views

No increment of a variable in a Sweave code chunk which is wrapped by a \whiledo loop

I already searched in different forums but until now I couldn’t find a solution. So I hope that you can help me… Like mentioned in the title there is no increment of my variable x in the code chunk ...
3
votes
0answers
93 views

knitr pdf search invisible text

I use the fantastic knitr to generate beamer-pdf’s with hundreds of slides of plots. Every plot shows data of different measuring equipment, so for example the plot showing result of measuring ...
0
votes
0answers
93 views

Knitr not available in LyX (Windows)

I installed LyX with MicTeX on my pc. I installed the Knitr module. So I see in the packages in R studio that I can add 'Knitr'. After that i added the path of R.home('bin') to the PATH in the ...
4
votes
3answers
362 views

What's the best .Rnw editor?

I'm trying to find out what people use for editing .Rnw files. Desirable features are: Auto R code completion Auto LaTeX code completion Cross platform Automatic display of R function documentation ...
1
vote
0answers
41 views

Trouble getting tikzDevice to work at all

Have used TikZ extensively over the years (MiKTeX is my LaTeX distro of choice), and recently, thought I'd try my hand at 'exporting' R graphics -> LaTeX used tikzDevice, which some folks have found ...
23
votes
2answers
16k 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 &...
1
vote
0answers
44 views

Produce multiple documents using a loop in LaTex

I want to produce multiple documents in LaTeX. There is a list of values for every document that should be created, in the example it´s \mylist. My first approach was to use the \foreach function to ...
0
votes
0answers
25 views

What does “LaTeX Error: Environment rmdtip undefined.” mean?

I am trying to build a book using bookdown::render_book() command in RStudio. However, it stops working after the pandoc step almost at the end of the process: "K:/Program Files/RStudio/bin/pandoc/...
1
vote
1answer
665 views

R assignment operator (“<-”)

How does one typeset the R assignment operator ("<-")? Workarounds such as \begin{description} \item[x \textless{}- c(1:3)] Create the vector [1 2 3] and assign it to an object named x. %...
1
vote
0answers
62 views

general footnotes in xtable

I am using sweave to create pdf. Using xtable, I am trying to insert a general footnotes under the table (i.e: This symbol means bla bla bla). I've tried a lot of things and everything get me an error ...
2
votes
1answer
67 views

How to create a latex table in R with significance stars?

I have a latex table generated as following in R: \documentclass[12pt,econ]{authesis} \usepackage{natbib} % natbib citation style \usepackage{url} % added 2015-067-06 bc the example .bib ...
8
votes
1answer
1k 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 ...
1
vote
1answer
34 views

\lstinputlisting with R problem

I'm trying to include my R code in a Lyx document but get the following error when trying to convert to PDF: \lstinputlisting{MonteCarlo.R} ^^M *** (cannot \read ...
1
vote
1answer
51 views

make the TeX xtable results well formatted and easier to read

Is there a way to make the TeX xtable source code results well formatted and easier to read. Example: library(xtable) ## Load example dataset data(tli) print(tli.table) gives \begin{table}[ht] \...
0
votes
0answers
17 views

mtable into LaTeX: ! Missing } inserted.<inserted text>}

I am trying to write my thesis with LaTeX (first time using it) and I am struggling with making some tables. I am using toLatex in R to produce an mtable, which gives me the following code: \...
5
votes
2answers
455 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, ...
1
vote
2answers
83 views

Where set font in tikzDevice-plots (.Rnw)

I'm trying to use sans serif fonts for the text in plots (ggplot2) made by R, within KOMA-book. Unfortunately I'm not very experienced in managing fonts and their families. To keep things consistent, ...
15
votes
2answers
3k 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 ...
2
votes
1answer
21 views

Set TeXstudio for Unicode .Rnw files (Sweave)

I tried to run Sweave on a .Rnw file from TeXstudio, but the unicode characters don't show up in the .tex file when I typeset with xelatex. My user command is /usr/local/bin/Rscript -e "Sweave('%.Rnw'...
3
votes
3answers
571 views

knitr sanitises the % marker for LaTex comments and they show up in the final document

I am writing a knitr document using xtable to get my tables. Xtable inserts by default a comment saying: "latex table generated in R 3.1.0 by stable 1.7-3 package % Thu Sep 18 14:19:21 2014" This ...
2
votes
1answer
136 views

2D correlation plot matrix with shapes

Is there a straightforward way to create a correlation plot matrix similar to the figure below? The image is an example of R's corrplot package using circles, which also offers other shapes and ...
0
votes
0answers
43 views

How to create an index for a book that includes code chunks

I'm in the process of creating an index for a book that includes R code chunks. I'd like to include certain R functions that appear in these chunks in the index, so I assume I have to place the \index ...
4
votes
3answers
123 views

How to extract a series of text not in an environment, but with defined commands enclosing them

Under Windows 8, I am using R and the knitr package in RStudio with an .Rnw script. My regex skills are passable, but only in R. My document has about thirty pages with a different text section at ...
0
votes
0answers
34 views

dplyr Tables latex problem

Can you explain why the caption of the table is not appearing in the example below. All works fine except the caption \begin{center} <<echo = FALSE>>= library(dplyr) myTable <- as....
2
votes
1answer
96 views

siunitx: What is the correct way to output mean and standard deviation as “M (SD)” in an S-column?

I am trying to use siunitx in a psychology results table to line up decimals, and the table looks like this: \documentclass[]{article} \begin{document} \begin{table}[h] \begin{tabular}{@{}cc@{}} ...
2
votes
2answers
190 views

Citations in tabular environment not working

I'm writing my thesis with Rmarkdown but with a lot of LaTeX mixed in. When I compile the document, all my citations appear just fine, but those in my table appear as [?]. I have tested different ...
1
vote
0answers
82 views

Writing R code in TeXstudio

I have one chapter of my document which include R code. Whole document is written in TeXstudio. I need help regarding writing and executing R code using Texstudio. Regards
1
vote
2answers
89 views

How to avoid page break after table?

I have a small LaTeX table (tabular) created in R with the xtable package and I would like to place a figure underneath the table on the SAME page. I have tried various things (using packages float, ...
133
votes
16answers
43k 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 ...
25
votes
1answer
18k 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 ...
1
vote
1answer
48 views

Following .Rnw works fine in RStudio but throws error in LyX

This .Rnw compiles fine in RStudio Version 0.99.862 \documentclass{book} \usepackage{Rd} % Rstudio will be able to find this .sty file \begin{document} <<label=Test, echo=FALSE, results='...
1
vote
1answer
172 views

How to align multiple equation using tcolorbox in latex enviroment for Rmarkdown

I have the following latex inside Rmarkdown: \begin{tcolorbox} \begin{equation} \sigma = \beta_{0} \label{eq:Model0} \end {...
1
vote
1answer
84 views

Including TikZ picture in Sweave gets me an overfull box error

I have some difficulties in R Sweave so I hope someone could help me. I want to include two TikZ pictures using minipage and figure to the R Sweave but I get an error: Overfull \hbox (2.43085pt too ...
1
vote
1answer
264 views

Sweave R code chunk default colors in vignette

Typically, if I create a .Rnw file and add R code chunks to it, and then convert it to .pdf file, the R code text will have default color and font than the rest of the document text. An example ...
2
votes
2answers
89 views

With knitr and LaTex, how can you arrange the List of Figures alphabetically?

What code will enable me to reorganize the List of Figures alphabetically (and keep the page number)? My goal is to include that alphabetical listing of figures in the PDF file that is created. Here ...
1
vote
0answers
532 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 &= \...