```{r}
#| include: false

library(ggplot2)
library(DT)
```



# Ta-dan

`ggplot2` is an R [@rsoft] package developed by [@ggplot]. @epifania2024 published an interesting paper on Linear Mixed Effects Models. 

## Quarto


```{r}
#| echo: fenced
#| column: margin

lm(hp ~ mpg*am, data = mtcars) # <1>

```


```{r}
#| code-fold: true
#| code-summary: "Show this code"
ggplot(mtcars, aes(hp, mpg, color = factor(am))) +
  geom_point() +
  geom_smooth(formula = y ~ x, method = "loess") +
  theme(legend.position = 'bottom')
```




<br>

<br>


```{r}
#| column: margin

datatable(mtcars,
  options = list(pageLength = 5))
```


Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.


::: {.column-margin}
I want this picture displayed in the margin


![](slides/01-Baby-steps/img/peacock.png)

:::




::: {.grid}

::: {.g-col-4}

First column, 4/12 of the toal width

:::

::: {.g-col-8}

Second column, 8/12 of the total width

:::

:::


## Running Code


When you click the **Render** button a document will be generated that includes both content and the output of embedded code. You can embed code like this:

```{r}
#| column: margin

lm(hp ~ mpg*am, data = mtcars)

```



```{r}
#| fig-column: margin
#| echo: false



ggplot(mtcars,
       aes(hp, mpg, color = factor(am))) +
  geom_point() +
  geom_smooth(formula = y ~ x, method = "loess") +
  theme(legend.position = 'bottom')

datatable(mtcars,
  options = list(pageLength = 5))

```

@tbl-tables presents two datasets: @tbl-tables-1 is cars and @tbl-tables-2 is pressure

```{r}
#| label: tbl-tables
#| tbl-cap: "Datasets"
#| tbl-subcap: 
#|   - "Cars"
#|   - "Pressure"
#| layout-ncol: 2

library(knitr)
kable(head(cars))
kable(head(pressure))
```

@fig-plotsModels illustrates different things. @fig-plotsModels-1 illustrates this, @fig-plotsModels-2 illustrates that and so on

```{r}
#| label: fig-plotsModels
#| echo: false
#| warning: false
#| column: screen-inset-shaded
#| layout-nrow: 2
#| layout-ncol: 2
#| fig-cap: "One dataset, different models" 
#| fig-subcap:
#|   - "The data"
#|   - "Polynomial"
#|   - "Linear Model"
#|   - "GLM with Poisson" 


ggplot(mtcars,
       aes(mpg, hp, size = gear)) +
  geom_point()

ggplot(mtcars,
       aes(mpg, hp, size = gear)) +
  geom_point() + 
  geom_smooth()

ggplot(mtcars,
       aes(mpg, hp, size = gear)) +
  geom_point() + 
  geom_smooth(method = "lm")
ggplot(mtcars,
       aes(mpg, hp, size = gear)) +
  geom_point() + 
  geom_smooth(method = "glm", method.args = list(family = "poisson"))


ggplot(mtcars, 
       aes(x = factor(cyl), y = mpg)) + 
geom_boxplot() +
        stat_summary(fun.data=mean_sdl,
                     geom="pointrange",
                    color="black") 

```
<br>

<br>


<br>

You can add options to executable code like this

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

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

