+ - 0:00:00
Notes for current slide
Notes for next slide

06

Tabs

1 / 10

Tabs

1

2 / 10

Dealing with long reports

There is a hierarchy of hashes for tabs

## Series Analysis {.tabset}
### Overview
### Ratings

Also

# Series Analysis {.tabset}
## Overview
## Ratings
3 / 10

Dealing with long reports

There is a hierarchy of hashes for tabs

## Series Analysis {.tabset}
### Overview
### Ratings

Also

# Series Analysis {.tabset}
## Overview
## Ratings

/ Screenshot of the tabsets with the headers as above

3 / 10

A Return space/carriage is required between the tabs OR two spaces after the line.

Note to start a tabset there have to be 2 hashes and not the main header of one #

Your turn

Looking at 01-bakeoff-report.Rmd together. Look at the source, then 🧶 Knit after each step.

  1. Add a header # Series Analysis {.tabset}.

  2. Change # Overview to ## Overview.

  3. Change # Ratings to ## Ratings.

  4. Remove the space in the second header ##Ratings. What happens?

03:00
4 / 10

Styling Tabs

2

5 / 10

Styling Tabs

# Series Analysis {.tabset .tabset-fade .tabset-pills}
## Overview
## Ratings
6 / 10

Styling Tabs

# Series Analysis {.tabset .tabset-fade .tabset-pills}
## Overview
## Ratings

Screenshot of the tabsets with the headers as above, pillsets have rounded edges

6 / 10

Dynamic tabs

3

7 / 10

Dynamic tabs

Together:

  1. We'll add a new header ## Days {.tabset .tabset-fade .tabset-pills}

  2. Ctrl + Alt + i for a new R chunk.

  3. Add the results='asis' in the chunk options.

  4. Create a list of days

days <- viewers %>% select(days) %>% unique() %>% pull()
  1. Copy loop code:
for(i in days){
cat("###", i, '<br>', '\n')
data <- viewers %>%
filter(days == i)
chart <- ggplot(data, aes(episode,
viewers,
colour = days,
group = days)) +
geom_point() +
geom_line() +
labs(
x = "Episode",
y = "Viewers (millions)"
) +
expand_limits(y = 0)
print(chart)
cat('\n', '<br>', '\n\n')
}
8 / 10

The new code chunk must be below the Ratings section as that's where the viewers data is created.

As with so much in R most things can be automated. If you were to require many tabs to be created for teams/wards/hospitals then automating this using a loop can be useful. First example shared in the NHS-R Community demos and how tos

results='asis'

On 'asis' Note the use of theresults='asis' chunk option. This is required to ensure that the raw table output isn’t processed further by knitr. The kable function includes several options to control the maximum number of digits for numeric columns, alignment, etc (refer to the knitr package documentation for additional details) - results slide https://lextuga007.github.io/rmd-workshop/slides/04-code-chunks.html#21

Time for a break!

10:00
9 / 10

Next section...

10 / 10

Tabs

1

2 / 10
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow