Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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
2answers
61 views

How Can I Get A LaTex Table Generated By R's MonteCarlo Package To Work?

I have been experimenting with the MonteCarlo package in R for a project. After using the maketable function, I was given the following code to generate a LaTex table with the Monte Carlo simulation's ...
0
votes
0answers
17 views

How do I get my output to fit into the gray box using knitr?

Some of my output is extending outside of the gray box by about 1-1.5 inches. How do I make the gray box bigger or the output smaller so it fits in the gray box and looks better?
2
votes
1answer
62 views

R Markdown/pandoc: Change how code blocks are converted to LaTeX

I use rmarkdown to generate a pdf file (which uses pandoc, which in turn uses pdflatex). By enabling keep_tex option, I noticed that code blocks without language type always become verbatim, e.g.: ```...
1
vote
3answers
53 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 ...
2
votes
1answer
47 views

How can I have a latex type expression as a column name in R?

I am working on many kables using the kableExtra package. Say you have a dataframe,df, that is 5 rows and 5 columns. in R you can do names(df)=c("A","B","C","D","E") for example. Once you have the ...
0
votes
1answer
30 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 ...
0
votes
0answers
44 views

Basic R code yields errors of “unclosed $” in knitr

I cannot use R code in Overleaf Knitr, since any basic code which includes $ yields error of unclosed $. Even the sample file of knitr in Overleaf itself causes LaTeX error: https://www.overleaf.com/...
0
votes
1answer
32 views

Problem when compiling book with bookdown - natbib error

I am creating a pdf-book with bookdown using the following YAML: --- site: bookdown::bookdown_site geometry: "left=4cm,right=3cm,top=3cm,bottom=3cm" subparagraph: true output: bookdown::pdf_book: ...
0
votes
0answers
28 views

When trying to compile a Rnw/sweave file I get a message that it failed, but it shows no warnings

I'm getting the following message: You can now run (pdf)latex on 'west-comparisons.tex' There were 50 or more warnings (use warnings() to see the first 50) Running pdflatex.exe on west-comparisons....
0
votes
2answers
143 views

How to use R's xtable() to print the output of table() and keep the row and column margin titles? and rotate

I need to generate many small tables from different pairs of vectors like this: (the vectors have names of different lengths) library(xtable) input1 <- c(0,0,0,1,1,1,1,2,2,2,2) input2 <- c(0,...
0
votes
1answer
25 views

Bookdown bibliography with natbib omits URL for web pages

I am creating a pdf-book using bookdown, with the citation package natbib in the apalike style. I get my citations from a .bib file created by mendeley. I create my citations like this: [@citation]. ...
2
votes
1answer
25 views

The following character ``[`` isn't working in table, error : ! Paragraph ended before \CT@rowd was complete. \par

I'll ask my question here since I think it has more to do with LaTeX than stackoverflow. I am using R Markdown with LaTeX to create pdf documents that shows some tables. Using the R language with ...
2
votes
1answer
46 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 ...
0
votes
0answers
46 views

Including R code in latex

I have some problems by inverting my R code into latex and than copying the code of the pdf back into R. I used lstlistning to read the R code and since it did not show the -, I used this code: \...
2
votes
1answer
29 views

Why can't I center my table using xtable and lualatex in rmd

Can anyone help me solving my issue with xtable, please ? I create a table using xtable, based on data that I processed Rstudio. The main R code runs a Rmd script who generates a pdf with that table....
1
vote
1answer
88 views

Is there a latex package for working with Rtex files locally

Working with Overleaf using .Rtex files and I love it. However, I just discovered that Overleaf does not support a lot of the R packages (e.g., tidyverse, sqldf) and does not work with large data sets....
0
votes
0answers
431 views

How to add cover pages to rmarkdown pdf file?

I need to add a coverpage at the very begginning and end of a pdf document i have made using R Markdown. (My first time using R markdown and latex) As it is now, the first page of the file output is ...
0
votes
0answers
18 views

Accessing variable in inline expression (rmd to pdf output)

I'm working on coding a reproducible rmd which will output a pdf document. I know that for an inline expression to work, it requires $ $ to be placed around it but is there a way around this? Client &...
1
vote
1answer
65 views

How to avoid the extension files when I compile pdf on r sweave

I face a problem when I compile pdf file I got many files in the working directory, for example, the files Untitled.tex and Untitled.toc along which my files Untitled.pdf and Untitled.Rnw. Can anyone ...
2
votes
1answer
190 views

Embedding R (kable) results in LaTeX

Apology at first if this question has been asked or the sample is not reproducible. I'm totally new to LaTex and happy to take any advice. I am working on my thesis on a .tex LaTex template given by ...
1
vote
1answer
551 views

Math symbol in Rmarkdown list

I am trying to get the following code to render correctly in rmarkdown, but unfortunately math mode does not seem to work in a list setting? Can anyone help with this? --- title: "Trial" author: "Jon"...
2
votes
2answers
66 views

How to make Manual references appear in bibliography (citing R)

I would like to cite R in my bibliography. However I'm having trouble getting it to appear. Here my mini.bib files contains @Book{, author = {Hadley Wickham}, title = {ggplot2: Elegant Graphics ...
2
votes
1answer
53 views

Manual bibliography in knitR with \bibitem{} works but cannot use \cite{} with it

I am trying to use a manual/embedded bibiography in a knitR/LaTeX document (long story short but for various reasons I don't want to be using a seperate .bib file because this script will be used many ...
2
votes
2answers
77 views

How to use \sexpr{} with variable that has “_” in it (i.e. avoid “math mode” error)

I am using knitr in R to write up a document in LaTex. Below a certain of code, I would like to refer to a variable I used in R. <<chunk>> var <- "ENSEMBL_MART_ENSEMBL" @ In this ...
2
votes
1answer
106 views

Can't remove italic format from my text with either \normalfont or \textnormal

$$\textit{Some italic and {\normalfont non italic} text}$$ $$\textit{Some italic and \textnormal{non italic} text}$$ My LaTeX block above is supposed to generate text like this (the first line): But ...
0
votes
0answers
420 views

Ubuntu 18.04 LTS Texlive 2018 ! LaTeX Error: File `ulem.sty' not found

After installing tinytex R package, I started getting LaTeX error regarding missing .sty files. One such error is LaTeX Error: File `ulem.sty' not found. I used the following code Checked Texlive ...
2
votes
1answer
56 views

Class tufte-book and R listings code box width problem

When I run the following MWE: \documentclass{tufte-book} \usepackage{Sweavel} \usepackage{amsthm} \usepackage{mathtools} \usepackage{soul} %%%%%%%%%% % R example %%%%%%%%%% \newtheoremstyle{rex}{}{...
1
vote
1answer
305 views

Disabling page numbering bottom of page

Newbie question here. I seem to have some trouble changing the page numbering. I want it in the header, instead of the bottom of the page. I got the header working, but I have been deleting and ...
3
votes
1answer
58 views

Tikz .tex file for a ggplot image made in R won't render as pdf in my tex document (but no compile error!)

I'll preface by saying that I'm not sure whether this is better off posted in StackOverflow, and I'd be happy to move it over there if that turns out to be the case. tl;dr I followed the ...
0
votes
0answers
214 views

Latex with rmarkdown (RStudio)

What must I do? This is pdfTeX, Version 3.14159265-2.6-1.40.19 (MiKTeX 2.9.6930 64-bit) entering extended mode Sorry, but C:\Users\Silvano\AppData\Local\Programs\MIKTEX~1.9\miktex\bin\x64\pdflatex....
1
vote
2answers
55 views

Environment undefined ONLY when referencing a preamble.tex

I'm trying to use R Markdown to typeset some notes and I'm having difficulty using the \adjustwidth environment. The issue only arises when I reference some preamble.tex. For instance, if I have a ...
0
votes
0answers
23 views

Indexing terms being used in cross-referencing

This is a follow-up question of my previous one: Cross-referencing numeric values and text from later section to executive summary of a latex document I have finished making my report and now my boss ...
2
votes
1answer
218 views

How to add page numbers to inline references using csl in rmarkdown?

I am using RMarkdown in RStudio to reference multiple sources out of my .bib file with csl (see below). My .Rmd doc: --- title: "mytitle" author: "nunberg" date: '01\.01\.2019' output: ...
1
vote
1answer
65 views

How to cite german book titles properly (upper case) with csl and rmarkdown?

I am using RMarkdown in RStudio and want to cite several sources using csl, specifically I use the style "elsevier-with-titles.csl". I want to cite a german reference, so title must have upper case ...
0
votes
0answers
187 views

Having problems with LaTeX coding in Rmarkdown (fancyhdr, \headheight)

I'm currently having an issue with latex in Rmarkdown (using fancyhdr package). I am trying to make a data report with a certain template style. This is a screenshot of the pdf at its current stage ...
2
votes
1answer
203 views

How to center and flush right cells in a column

I am trying to create a table with a numeric column number which I wish to center and flushright content as follows: Using RMarkdown, I am only able to wrap LaTeX code around/inline with cell content ...
3
votes
2answers
633 views

Reporting R Results in LaTeX

I´m writing my thesis in LaTeX (using Overleaf) and I analyzed some data in R. So I have a R script where I perform a bunch of tests and regressions. Now I want to e.g. include the t-statistic and p-...
0
votes
3answers
863 views

Can I type \LaTeX inside inline code in Rmarkdown?

I know I can use $$ to write \LaTeX in Rmarkdown documents like $\beta$. My goal is if this is possible inside inline code. I would do `$\beta$` or `$\\beta$`, but both do not work. In case it is ...
1
vote
1answer
290 views

Importing entire R Script file into Latex

Is there a way to import an entire RScript (.R) file into Latex directly without manually using listings and copying the code into Latex?
0
votes
1answer
224 views

R Markdown preview LaTeX by scrolling over

I believe in the past I have been able to preview my LaTeX code in R Markdown by just placing the cursor over the LaTeX chunk, but right now I'm unable to recreate that. Any idea how to turn that back ...
0
votes
2answers
121 views

Table of contents in Beamer R Studio

i'am trying to generate an beamer presentation but i can't add an Ouline of my document: this is my code: --- title: 'PEC-3 Gestión Económico-Financiera: Casos de Negocio. El sector de la ...
0
votes
2answers
100 views

side by side tables latex - without \floatrow

I have the following simplified document (): \documentclass[10pt]{book} \usepackage{float} \let\origfigure\figure \let\endorigfigure\endfigure \renewenvironment{figure}[1][2] { \expandafter\...
0
votes
1answer
580 views

How to write y i = β 0 + β 1 x i + β 2 x 2 i + e i in Latex code? [duplicate]

I'm a beginner of using R and Latex. Just wonder how to write yi = β0 + β1xi + β2x2i + ei by using Latex?
0
votes
1answer
95 views

How to use if-else statements in sweave documents

Is there a way to use an if-else statement in an sweave document, so that a figure is only shown depending on the value of an R object. I tried different approaches (two of them are below), but I did ...
0
votes
0answers
93 views

Converting Tab-delimited reference list into a bibtex format (using R?)

I need to export search results from Web of Science (i.e. all the results of a query, 100s of entries) and import them in Mendeley with their abstract. while I usually can export a citation in a .bib ...
0
votes
1answer
313 views

mathbb not working and mathbbm/mathds not compiling in rmarkdown [closed]

I'm trying to get the math 1 character in an rmarkdown file. \mathbb{1} just produces a simple 1, and \mathbbm{1} / \mathds{1} does not compile for some reason. title: "A3" header-includes: - \...
2
votes
1answer
239 views

Getting R xtable to display within a LaTex 'minipage'

I have the following piece of R-markdown / latex / minipage combo code. What I am trying to do is get the xtable output to display within the minipage, along with other text paragraphs surrounding it....
2
votes
1answer
233 views

Caption in Sweave after an R plot

I have the following R chunk: <<echo=FALSE>>= par(mfrow=c(3,1)) #cas basal: no negra no fumadora sense prematurs ni hipertensi? lwt.pred<-seq(80,250,1) prob.pred<-0+model.final$...
0
votes
1answer
41 views

How to set roman font to make references to R? [duplicate]

I'm writing a thesis and I need to make references to R. I've read some other articles that cite "R" and they seem to use the roman font. I have no idea how to set this font :(
2
votes
1answer
806 views

Undefined control sequence in R markdown

I have got stuck on this code which I could not be able to find that in my content anymore after checking for more than two times. Is there any packages I should have updated? As I am using TexShop ...