datacamp / datacamp-light

Convert any blog or website to an interactive learning platform for data science
GNU Affero General Public License v3.0
1.31k stars 358 forks source link

An interactive learning widget for R using Quarto #204

Open prupk opened 1 year ago

prupk commented 1 year ago

The following Test.Rmd will produce an interactive learning widget for [tag:R] using [tag:knitr] (see the link).

---
title: "Example Document"
author: "Your name here"
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
```

Edited

Wondering how to an get an interactive learning widget for [tag:R] using [tag:quarto]. Need help for YAML of .qmd, my attempt is

    ---
title: "Test"
author: "MYaseen208"
format: 
  html:
    self_contained: false
---

```{r}
#| echo: false
#| include: false
tutorial::go_interactive()
```

```{r}
#| echo: false
1 + 1
```

You can add options to executable code like this 

```{r}
#| echo: false
2 * 2
```

The `echo: false` option disables the printing of code (only output is displayed).

However, it throws the following error:

ERROR: Validation of YAML front matter failed.
ERROR: (line 5, columns 3--7) Field "html" has empty value but it must instead be an object
4: format: 
5:   html:
        ~
6: ---

ERROR: Render failed due to invalid YAML.

Another attempt which render but don't produce the required output:

---
title: "Test1"
author: "MYaseen208"
format: 
  html:
    output-file: "Test1.html"
    self-contained: false
---