5

The data frame is not being printed over the width of the (assumed) box, but the last column is being cut and printed below. This happens with (see example picture) or without {.smaller} class.

How can I change the width of the box that is used for data frame printing? Ideally a dynamic width that adjusts to the width of the window, but I'd be happy with fixed widths too.

---
title: "Untitled"
format: revealjs
editor: visual
---

## "amd" data set from R package eyedata {.smaller}

```{r}
head(eyedata::amd, 15, row)
```

Example figure

enter image description here

tjebo
  • 21,977
  • 7
  • 58
  • 94

1 Answers1

2

You could use options to change the width like this:

---
title: "Untitled"
format: revealjs
editor: visual
---

## "amd" data set from R package eyedata {.smaller}

```{r}
options(width = 999)
head(eyedata::amd, 15, row)
```

Output:

enter image description here

You could do this per code chunk:

---
title: "Untitled"
format: revealjs
editor: visual
---

## "amd" data set from R package eyedata {.smaller}

```{r}
options(width = 999)
head(eyedata::amd, 15, row)
```

```{r}
options(width = 80)
head(eyedata::amd, 15, row)
```

Output:

enter image description here

This is what the width argument can be used for ?options:

controls the maximum number of columns on a line used in printing vectors, matrices and arrays, and when filling by cat.

Columns are normally the same as characters except in East Asian languages.

You may want to change this if you re-size the window that R is running in. Valid values are 10...10000 with default normally 80. (The limits on valid values are in file ‘Print.h’ and can be changed by re-compiling R.) Some R consoles automatically change the value when they are resized.

Quinten
  • 35,235
  • 5
  • 20
  • 53