---
title: "Flexdashboard example (Palmer Penguins)"
output:
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(palmerpenguins)
library(tidyverse)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
ggplot(
  penguins,
  aes(x = bill_length_mm, y = bill_depth_mm, color = species)
) +
  geom_point()
```

Column {data-width=350}
-----------------------------------------------------------------------

### Chart B

```{r}
DT::datatable(penguins)
```

### Chart C

```{r}
roundval <- 2
cleanmean <- function(x, roundval = 2, na.rm = TRUE) {
  return(round(mean(x, na.rm = na.rm), digits = roundval))
}
summarystat <- penguins %>%
  group_by(species) %>%
  summarize(
    `Average bill length (mm)` = cleanmean(bill_length_mm),
    `Average bill depth (mm)` = cleanmean(bill_depth_mm)
  )
knitr::kable(summarystat)
```