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
2
votes
1answer
243 views

Tex code generated with R huxtable package has parts of it displayed in the output

I have some trouble with the generation of a standalone pdf of a table in a R script. I use huxtable R package to create a "latex" table from a regular R matrix or dataframe. Hereunder is a very ...
1
vote
2answers
1k views

What's the illegal character in Stargazer LaTeX output for Regression Table?

I'm trying to use a stargazer LaTeX output for a basic OLS regression table in R, but the compilation keeps breaking down in the \begin{tabular}{@{\extracolsep{5pt}}ld{.}{.}{-3}} line due to an ...
0
votes
1answer
186 views

LaTeX syntax for “newcommand” and “cat” [closed]

I have the following command with use of the "cat" function: cat("\\newcommand{\\NetFlowFull}{",ifelse(Direction=="Buy","raise","invest")," ",NetFlow,"}",sep="") where "Direction" and "NetFlow" are ...
0
votes
0answers
59 views

Using R plot in Latex output - not finding saved .png [duplicate]

I am trying to create a plot in R and use knitr and latex to print that plot to a pdf. I think I am taking the correct steps: 1. save plot as .png in same folder as .tex file 2. write this into the ...
1
vote
1answer
272 views

Flipping headers on even and odd pages with fandyhdr doesn't work

When using the fancyhdr package in Rmarkdown the header does not flip as code would expect. I have always author on the left and page number on the right. What's wrong? This is my Rmarkdown file: ---...
0
votes
1answer
147 views

how to transform automatically a regular tabular into a tabularx?

Consider this simple tex table \begin{tabular}{llrr} \toprule \multicolumn{2}{c}{Text} & \multicolumn{2}{c}{Values} \\ \cmidrule(l{2pt}r{2pt}){1-2} \cmidrule(l{2pt}r{2pt}){3-4} mytext1 & ...
0
votes
0answers
115 views

Is it possible to nest multiple overset? otherwise how?

I have a ggplot2 plot for which I'd like to align text to some plot related boundaries e.g. between axis ticks. The process that creates the annotation text is automatic and needs to account for word-...
1
vote
1answer
503 views

R code and Sweave output - EDIT

UPDATED Question 1 In the lattest update of KnitR the output is clean as what I expected. Maybe an update was made. The new output : Before update I'm trying to get a particular output with Sweave ...
1
vote
0answers
180 views

R Sweave: print very large dataframe sample which spans on multiple pages inside a floating environment

I'm using R Sweave to output an R document into a LaTeX file through R Studio on a Windows 7. I have a very large data frame from which I have to put a sample at the begin of my document. I use xtable ...
2
votes
1answer
409 views

Todo and rmd-generated LaTeX document

How to use the todo package in R Markdown-generated LaTeX documents? To load packages, it is possible to add them to the document's header with header-includes:. This successfully works with \...
0
votes
1answer
508 views

Trying to get rid of the included chunk in sweave document.

I just translated the mosaic manuals and I'm giving format to them. I'm using this chunk for all the packages, but it's still printing me the whole chunk at the first page of the book: <<...
1
vote
1answer
1k views

Include a tikz diagram latex code to Rmarkdown

How to include following Latex code to Rmarkdown? \usetikzlibrary{shapes.geometric,arrows} \tikzstyle{decision} = [ diamond, draw, fill=blue!20, text width=4.5em, text badly centered, node distance=...
0
votes
0answers
353 views

How can I preview the output of a RNW file?

I currently create pdfs in RStudio by calling the knit2pdf function on a RNW file. However, when playing around with the LaTeX formatting in the RNW file, I'm wondering how I can preview my results? ...
3
votes
1answer
506 views

Table spacing issue converting to PDF via LaTeX with pandoc

In the application of Rmarkdown I often found my answers concerning “LaTeX” and “pandoc” here at TeX Stackexchange. For that reason I want to repeat here my question I asked at stackoverflow hoping to ...
0
votes
1answer
255 views

Colour definition in LaTeX- xcolor.sty, svgnam.def, and \definecolor

I'm looking for the best way to define a new colour in LaTeX using the different methods above. In xcolor.sty, I have \definecolorset{gray/rgb/hsb/cmyk}{}{}% {black,0/0,0,0/0,0,0/0,0,0,1;% ...
-1
votes
1answer
309 views

xcolor package will not map text to color

I downloaded the xcolor package from the CTAN website, which includes xcolor.sty, svgnam.def, and xcolor.pro. The table that I output contains the name of the color in text, without the actual color. ...
3
votes
2answers
1k views

Create R code in LaTeX which can be directly copied and executed in R

I would like to create R code in a latex document, which is directly executable, when copied into an R environment. I use the following MWE, but the <- and the * can't be properly interpreted by R. ...
9
votes
1answer
26k 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)?
0
votes
1answer
102 views

Losing detail of pdf images in latex

I have a plot in R and i saved as a pdf. Now i want to include that in latex. That's the pdf file in R and in LATEX i'm getting crazy on this, why the points on the plot simply disappear????
2
votes
1answer
145 views

Package Listings and use of $ and % on code R

My code doesn't compile, what i do? The problem is on symbols $ and %! Log of errors: link \documentclass{report} \usepackage[brazil]{babel} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \...
0
votes
1answer
621 views

Display R code in Latex (with highlighted color)

How can I type R syntax in Latex(with the color like green, blue, gray for text)? And also the symbol ```. Thank you
0
votes
0answers
64 views

Why is an extra page inserted before the cover page when changing page colors for a single page?

I am using R and the knitr package to produce a LaTeX PDF. As the MWE below demonstrates, an extra, blank page is created before my boxed page, which is to be the cover of a book. If I remove the ...
1
vote
0answers
1k views

Specify multiple notes of a table by xtable

I want to create a table which may contain multiple notes like : which I found here. This works fine in a pure LaTeX context, yet I'm using knitr to convert my Rnw files (under R) to pdf, because ...
0
votes
1answer
1k views

Latex Error: File ended while scanning use of \Gscale@box

I'm having trouble locating the source of this error. Overview_page1 (passed to FormattedTable), is currently a character of length 33- after running my code, it becomes a 3x11 table. However, when I ...
5
votes
1answer
2k 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: ...
2
votes
2answers
1k views

Generate Table with Greek letters and multicolumns in rstudio for latex

With the commands: --- output: pdf_document --- ```{r, results='asis',message=FALSE,warning=FALSE} library(knitr) library(xtable) url <- 'https://cdn.rawgit.com/fsbmat/StackOverflow/master/' ...
1
vote
0answers
82 views

Incorporating R code in problem sheets of probsoln

While working with the probsoln package, how can I include R code in problem sheets? My main document is \documentclass{article} \usepackage{probsoln, verbatim} \PSNrandseed{200} \begin{document} \...
4
votes
1answer
641 views

Removing all hlines in xtable generated longtables

Even by setting hline.after = NULL, a longtable generated by the R package xtable still mantains an hline at the very end of the table. \documentclass{article} \usepackage{longtable} \begin{...
2
votes
1answer
551 views

Generated Greek letters in plots using the tikzDevice package

With the code below I create in Rstudio the file gamma0plot.tex. Then in TexNicCenter in the figure environment with the input command I load the file gamma0plot.tex and generate a .pdf file. In This ....
2
votes
1answer
8k views

How to centre and bold a heading in RMarkdown and LaTeX?

I am a new LaTeX and RMarkdown user. I am currently compiling reports using RMarkdown (in RStudio) but am unsure how to centre and bold one of my headings? For example, my document looks like this: --...
4
votes
1answer
412 views

Can't set singlespacing for code chunks only

I'm just going to put the question inside an example .Rnw code block. It's easiest to see the problem when this is compiled into a .pdf file. I'm using pdfLaTeX and knitr to compile the file from ...
8
votes
1answer
26k 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 ...
0
votes
1answer
106 views

Own equation environment for - R syntax formulas

I'd like to be able to write down formulas in R syntax as equations, i.e. I'd like to do something like this: \begin{requation} time ~ (poly(I(1/nprocs), 2) + poly(ndoms, 2) + poly(nDOF, 2))^3 \end{...
1
vote
1answer
1k views

Passing Variable from R to LaTeX

Consider a variable in R, say YEAR <- 2000 I have various files whose names are dependent on this year, say YEAR 1.pdf, YEAR 2.pdf. Is there a way for me to pass this variable into a .rnw which ...
3
votes
2answers
11k 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 &...
1
vote
1answer
499 views

How to insert many tikzpicture R plot images as .tex files inside a table of images in LaTeX?

I can include my R plots in a LaTeX document using tikz package (on the LaTeX side) and tikzDevice package on the R side. I produced many .tex files containing my plots in R using as an example the ...
0
votes
1answer
1k views

Including greek letters when saving matrix from R to .tex table

How does one save a table with Greek letters in R, so that LaTeX recognizes and outputs the Greek letters when the table is called in LaTeX ? I am using R to output a table of results, save the ...
1
vote
1answer
188 views

R code block causes LaTeX errors with Knitr

I am using R with knittr and LaTeX. I have isolated some error that has been occuring the following block: <<>>= opt_vals <- data.frame(opt_length=numeric(2000), ...
0
votes
1answer
160 views

R: associating list elements to a LaTeX file

I am implementing a factorial survey experiment in R and I need your help to increase the speed of survey implementation. In factorial surveys, respondents are randomly assigned to a 'deck' of n ...
0
votes
0answers
114 views

R tikzdevice relative directories

I asked this on SO, but perhaps it is more relevant here: This is a problem which I face with many many plots. In R, Lets say I create a ggplot2 plot, with a colourbar: R> sample = ggplot(data=...
1
vote
0answers
831 views

load latex table to r markdown [closed]

I have some latex tables that I generated via stata. I am trying to incorporate them onto r markdown so that I can create a comprehensive pdf with all the figures (some generated in r markdown, some ...
2
votes
1answer
335 views

TexStudio highlighting

I'm using a number of \Sexpr statements in my Rnw file. They contain $ symbols and this results in e.g. The result is very messy green highlighting in inappropriate places and a hard to read file. ...
1
vote
1answer
314 views

longtable and colortbl

I'm trying to color specific rows (with MES >= 8) but for some reason, it doesn't work for the first line. I'm running a R Markdown (xtable package to create the table). print(xtable(m8.c(SC), ...
0
votes
1answer
2k views

How can I insert some R code (as just plain text) into LaTeX [duplicate]

I'm writing a report for a course and we need to include our R script in the appendix of our report (It just needs to be like it would in a plain text file, just in LaTeX. How can I insert this? My ...
0
votes
0answers
189 views

With R, knitr and RStudio, how do you compile a .dtx file to get the .sty file needed for a package?

Working through Stefan Kottwitz's LaTeX Cookbook, page 82, I tried to use the package pullquote. I am using R, the knitr library and the RStudio IDE. When I compiled the .Rnw script that has the ...
0
votes
0answers
98 views

R-codes in LaTeX using listings

I use the package listings to include R-codes in my project. Unfortunately, it produces (sometimes, but not always) a hanging indent in the pdf document. Is there a possibility to erase this ...
3
votes
1answer
364 views

include python and R code in same two column article

I have bench oh Python and R code which I like to insert into my LaTeX article. How can I include .py or .r code file ?? I did this before with Matlab like this: \begin{center} \begin{figure} \...
2
votes
0answers
236 views

R and LaTeX: Why does white-space character disappear from path?

I'm creating a manual for an R package using LaTeX, and I have to follow a specific latex style . So, I want to create PDF using well known pdflatex, starting form .tex file generated by 'knitr'. ...
3
votes
3answers
1k views

Creating diagrams with LaTeX or R

I'm, trying to create an horizontal diagram (like the diagrams you can create with Visio but programatically) in R (to embed it in a LaTeX document) or directly in LaTeX. So far I've been reading ...
2
votes
1answer
281 views

Modify the layout of a Table-1 filled with data from R

I want to fill automaticly data from R into a table for a TeX-document. Sweave and Knitr are possibilities here. Please feel free to add more. (I know Sweave and Knitr are R package but the focus of ...