Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using datacamp light exercises in an ioslides presentation using the tutorial package

The tutorial packages allows to include a datacamp interactive R window in an html document:

    ---
title: "Example Document"
output:
  html_document:
    self_contained: FALSE
---

```{r, include=FALSE}
tutorial::go_interactive()
```

By default, `tutorial` will convert all R chunks.

```{r}
a <- 2
b <- 3

a + b
```

I therefore thought it might be able to use it within an HTML5 presentation, for example like this:

---
title: "Example Document"
output:
  ioslides_presentation:
    self_contained: FALSE
---

```{r, include=FALSE}
tutorial::go_interactive()
```

By default, `tutorial` will convert all R chunks.

```{r}
a <- 2
b <- 3

a + b
```

However, that only created nonsense. Has anyone experience in getting this to work?

P.S.: The best result so far is a long alphanumeric string instead of a console in browser window (Google Chrome).

like image 604
Joanne Demmler Avatar asked Nov 27 '25 18:11

Joanne Demmler


1 Answers

In the converting process, the HTML generated by the tutorial package gets encoded. An easy solution is to wrap your chunks like this:

<!--html_preserve-->
```{r}
a <- 2
b <- 3

a + b
```
<!--/html_preserve-->

leading to the HTML code generated being untouched.

enter image description here

To fix the glitches resulting from CSS conflicts you can add the following CSS right at the beginning of your document:

    <style>
/* Rearrange console label */
.datacamp-exercise ol li, .datacamp-exercise ul li {
  margin-bottom: 0em !important;
}

/* Remove bullet marker */
.datacamp-exercise ol li::before, .datacamp-exercise ul li::before {
  content: '' !important;
}
</style>

enter image description here

like image 99
Martin Schmelzer Avatar answered Nov 29 '25 09:11

Martin Schmelzer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!