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.

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. R was created by Ross Ihaka and Robert Gentleman and is now developed by the R Development Core Team. It is easily extended through a packaging system on CRAN.

Official documentation from CRAN

  • An Introduction to R PDF HTML - A basic introduction for beginners.
  • The R Language Definition PDF HTML - A more technical discussion of the R language itself.
  • Writing R Extensions PDF HTML - Guide to writing packages for R, help files and foreign language interfaces.
  • R Data Import/Export PDF HTML - Guide to importing/exporting data in R in various formats.
  • R Installation PDF HTML - Guide to installing R from source.
  • R Internals PDF HTML - Outlines R's internal structures and coding guidelines for the R Core Team.

Other free resources

  • The R Inferno (Patrick Burns) PDF
  • R by example
  • CRAN maintains an extensive list of free contributed documentation in a range of languages.

Other Resources:

Syntax Highlighting

If your question or answer contains R code, you can enable syntax highlighting by doing the following:

<!-- language: lang-r -->

    R code goes here

For example, here's how this works on a “Hello, world!” program:

# A "Hello, world!" program.
hello <- function() {
    sprintf( "Hello, world!");
}

See here for a more detailed overview of syntax highlighting on Stack Exchange.

Frequently asked questions:

R FAQ - Official list of R FAQs on CRAN

597 questions
31
votes
5 answers

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 version. This typically indicates Rd…
Tal Galili
  • 1,389
26
votes
1 answer

Export tables from R to LaTeX

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 because while I have been able to export html and text…
18
votes
2 answers

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
  • 1,465
10
votes
2 answers

How to Insert into Latex a Text File whose name is a variable?

I need to insert a text file into LaTeX. But text file names are different for different projects. So I want to define text file name as a variable and refer to the variable when inserting the text I tried the code as below. But…
user1317643
9
votes
2 answers

How do I add multiple conditions to \ifthenelse?

Thank you in advance for any help. How do I add multiple conditions to \ifthenelse? I want to be able to write: \ifthenelse{varType equals 'HS' and metric equals 'KPI1'} {do this} \ifthenelse{varType does not equal 'HS' and metric equals…
Pawel
  • 203
6
votes
1 answer

exporting R ggplot2 plots to LaTex

I usually export ggplot2 plots from R using "Save As" PDF and works fine, then I use \includegraphics from LaTex to include the fig. The problem is that it seems that the amount of data in these exported PDF from R are big e.g. over 600K each. If I…
SkyWalker
  • 1,897
5
votes
1 answer

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 with the jpg at scale 25%, 50 and…
Fran
  • 80,769
5
votes
1 answer

LaTeX "command" /incantation for R

I am using the tufte-handout class in LaTeX and I want to refer to R using the "correct" sans-serif font. I am currently using \newcommand{\R}{ {\bf \sffamily R } } used as ... ... function in the \verb|spatstat| \R package ... What LaTeX…
Sean
  • 491
5
votes
1 answer

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. %Illustrates workaround 1. \item[y $\leftangle$-…
5
votes
1 answer

lstlisting wrongly parse code as stringstyle (language = R)

please have a look at this picture. Could someone help me solve this please? As you can see, lstlisting sees my code chunk as string, which should not be the case (only stuff in quotes should be in mauve). Here's a minimal…
Wet Feet
  • 611
  • 1
  • 5
  • 11
4
votes
0 answers

TeX-function for writing R-functions

I'm working on an introductory course for the R-language in Latex, so I'm trying to write a Latex function that displays the R-function. This is what I've got: \makeatletter \newcommand{\fun}[3]{ \begin{tcolorbox}[top = 0mm, bottom = 0mm,…
m00se
  • 41
3
votes
2 answers

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-value in the Text. x <- rnorm(10, 180, 10) y <-…
MoRitz
  • 45
  • 6
2
votes
0 answers

R figure to LaTeX - cloudy and diffuse text

I am a newbie to R and LaTeX, and cannot find any hint for my problem. Perhaps it is a silly question, but I tried to get a R-diagram into my LaTeX document without the axes out of focus. So far so good, in R I used the following…
Kaddi
  • 21
1
vote
1 answer

Formatting like R in Latex document

I'm an extreme beginner. I would like to write the names of R packages like "lavaan" in the screenshot attached, but I really don't know how to achieve that. Can anyone help? I would only format one word at a time like this.
1
vote
0 answers

R: Prettify xtable() output for printing a matrix or dataframe

Following a suggestion, this is a repost from stackoverflow. I am trying to print out this table from R using xtable(). The default output is ugly. Is it possible to embed latex code within xtable() to manipulate what individual columns look like?…
user3671
  • 655
1
2 3