0
votes

I currently work on a beamer presentation with markdown in RStudio. I have some codechunks which generate output and I want to format the output in certain ways. This is one slide:

---
title: "An Introduction to Statistical Analysis with R"
author: Me
date: Now
output: 
  beamer_presentation:
     slide_level: 3
---

# Lecture 2: Creating datasets with R

### Assignments

R, like other computer languages, has *symbolic variables*, that is
names that can be used to represent values. To assign the value 2 to the
variable `x` and then work with it, you can enter

```{r, collapse=TRUE}
x <- 2
x
x+x
2*x+exp(x)
2*x*pi
```

Currently the output from the code chunk in the PDF file looks like this:

x <- 2
x
## [1] 2 
x+x
## [1] 4 
2*x+exp(x)
## [1] 11.38906 
2*x*pi
## [1] 12.56637

I want to change the font and the colour of generated output (i.e. the hashed lines). I also would like to space the output from the code so it looks like this:

x <- 2
x

## [1] 2 

x+x

## [1] 4 

2*x+exp(x)

## [1] 11.38906 

2*x*pi

## [1] 12.56637

How can I achieve this? I am not great with knitr (especially syntax). From what I have read so far hooks could be useful? Also I would like to implement the proposed changes globally.

1

1 Answers

0
votes

Just add spaces in your Rmd chunk and they will carry through to beamer (they do on my setup, R 3.6.1 on Windows 10). The colors automatically configure in beamer.

```{r, collapse=TRUE}
x <- 2
x

x+x

2*x+exp(x)

2*x*pi
```

enter image description here