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
42 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 ...
3
votes
0answers
37 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
11 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
58 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
1answer
55 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
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
86 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 ...
2
votes
1answer
48 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 ...
4
votes
3answers
349 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
32 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 ...
22
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
36 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
22 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
622 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
56 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
57 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
31 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: \...
3
votes
2answers
346 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
76 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
20 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
560 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
116 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
38 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
117 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
33 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
74 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
171 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
78 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
83 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, ...
131
votes
16answers
42k 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 ...
24
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
148 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 {...
21
votes
3answers
759 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 ...
1
vote
1answer
76 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
239 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
82 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
450 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 &= \...
2
votes
1answer
62 views

Insert line break into knitr fig.cap?

I am using knitr and want to insert a line break in my fig.cap chunk option. Is this possible? The following is all I can think of but it doesn't work. I expect there's some evaluation option but I ...
2
votes
0answers
54 views

What is the counterpart in LaTeX for the R package ezknitr and its tools for managing paths and directories

Dean Attali has just added an R package called ezknitr to CRAN. It enables those who use knitr and RMarkdown in .Rmd files to handle directories quite flexibly. His blog describes it well: path ...
2
votes
0answers
25 views

Graphics prepared with Sweave and text disorder

I am preparing a report using Sweave, it is really beautiful, but the first introductory words of my pdf-file appear after the first R-plot! How to fix it? I would like to add that I've already tried ...
1
vote
0answers
680 views

Error 43 while knitting a markdown to pdf in a R project created on mac and run on Windows

I created a R project which outputs some plots to pdf using rmarkdown::render with an .Rmd file. I shared the folder when the R project and all the relative files are kept to a colleague using Google ...
0
votes
1answer
192 views

Error in compiling LaTeX (bmcart.cls not found)

I'm a complete beginner to LaTeX. I want to try a latex template, so I: Created a new R Sweave file in RStudio Copied and pasted the source in https://www.overleaf.com/latex/templates/biomed-central-...
1
vote
1answer
204 views

Capturing final figure caption using knitr

I'm writing a paper for the journal PLOSone. They require that figure captions be placed in the article but not the figure itself (it's submitted separately). So I'm wondering how to get knitr to ...
2
votes
0answers
51 views

Knitr Plot Tooltips for ADA Compliance

I would like to use Knitr to generate plots in R that have hover-over tooltips. Here is a working example without an R tooltip: \documentclass{article} \usepackage{pdfcomment} \begin{...