/
examples.Rmd
52 lines (43 loc) · 1.38 KB
/
examples.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
title: "Example books"
---
The [bookdown contest](https://bookdown.org/home/contest/) is a great place to find a wide range of example books made with **bookdown**.
See a full list of books built with bookdown here: <https://bookdown.org/>
See below some featured books:
```{r, include = FALSE, eval=FALSE}
# rerun to change the example yml file
library(rvest)
url <- "https://bookdown.org/home"
html <- read_html(url)
books_node <- html %>%
html_nodes(".article-list")
books_info <- books_node %>%
purrr::map(~{
res <- list(
title = html_node(.x, "h1 > a") %>% html_text(),
img = html_node(.x, ".thumbnail > a > img") %>% html_attr("src"),
href = html_node(.x, "h1 > a") %>% html_attr("href"),
source = html_node(.x, "a.github-button") %>% html_attr("href"),
showcase = TRUE
)
res[is.na(res)] <- NULL
res
})
yaml::write_yaml(books_info, "examples.yml")
```
```{r, include=FALSE, eval=FALSE}
# remove some books from showcase
books_info <- yaml::read_yaml("examples.yml") %>%
purrr::map(~{
# some of our books
no_show <- grepl("yihui|adv-r|rstudio|r4ds|r-pkgs", .x$href)
# books with no source code repo
no_source <- is.null(.x$source)
if (no_show || no_source) .x$showcase <- FALSE
.x
})
yaml::write_yaml(books_info, "examples.yml")
```
```{r, echo = FALSE}
quillt::examples("examples.yml", showcaseOnly = TRUE)
```