-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport-webpage.Rmd
89 lines (65 loc) · 4.11 KB
/
report-webpage.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
title: "Report with Rmd Options"
author: "Diana LaScala-Gruenewald"
date: "7/23/2021"
output:
html_document:
toc: yes
toc_float: True
number_sections: yes
code_folding: hide
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Setup
The easiest way to create a website is to start a new project in RStudio and select the website template. This will create the desired file structure. This structure includes:
- `_site.yml` - how you control navigation for your website
- `index.Rmd` - which you can edit in Rmarkdown to create content
If you knit with just the default template, you will already have a simple website.
# Add options
Now let's add some options. The easiest way to do this is to click on the gear icon and select Output Options. Select "Include table of contents" and "Number section headings." You will see the yml at the top of the Rmarkdown file change.
## Here is a subheading
### Here is a sub-subheading.
See how the numbers increment?
# Add options continued
Other useful options include adding `toc_float: True` to the yml to create a floating table of contents, or `code_folding: hide` to the yml to hide the code. The latter will give you a button to open or close the code provided that `echo = True`. You can set echo in the "r setup" chunk at the top of the Rmarkdown file, or for each chunk individually.
Try code folding with this code chunk:
```{r}
print('Hello world.')
```
# Add equations
To add equations, enclose the equation with two dollar signs on each end.
$$
E = mc^2
$$
# Add tables
To add a table, if you have the data set, it's best to just use `knitr::kable(my_dataframe)`.
You can also copy and paste from an Excel spreadsheet into the visual editor, and it'll create the Rmarkdown syntax automatically in the .Rmd file. You really don't want to create a data table by hand in Rmarkdown if you can help it.
+------------+-----------------+----------+----------+----------+-------------+
| date_email | date_dive_start | rov_name | rov_code | dive_num | request_num |
+============+=================+==========+==========+==========+=============+
| 3/11/21 | 12/7/20 | Ventana | 988 | 4317 | 1 |
+------------+-----------------+----------+----------+----------+-------------+
| 3/11/21 | 12/7/20 | Ventana | 988 | 4317 | 1 |
+------------+-----------------+----------+----------+----------+-------------+
| 3/11/21 | 12/8/20 | Ventana | 988 | 4318 | 2 |
+------------+-----------------+----------+----------+----------+-------------+
| 3/11/21 | 12/9/20 | Ventana | 988 | 4319 | 3 |
+------------+-----------------+----------+----------+----------+-------------+
| 3/11/21 | 12/9/20 | Ventana | 988 | 4320 | 4 |
+------------+-----------------+----------+----------+----------+-------------+
| 4/25/21 | 3/3/21 | Ventana | 988 | 4321 | 5 |
+------------+-----------------+----------+----------+----------+-------------+
| 4/25/21 | 3/4/21 | Ventana | 988 | 4322 | 6 |
+------------+-----------------+----------+----------+----------+-------------+
| 4/25/21 | 3/8/21 | Ventana | 988 | 4323 | 7 |
+------------+-----------------+----------+----------+----------+-------------+
| 4/25/21 | 3/9/21 | Ventana | 988 | 4324 | 8 |
+------------+-----------------+----------+----------+----------+-------------+
| 4/25/21 | 3/10/21 | Ventana | 988 | 4325 | 9 |
+------------+-----------------+----------+----------+----------+-------------+
| 4/25/21 | 3/10/21 | Ventana | 988 | 4326 | 10 |
+------------+-----------------+----------+----------+----------+-------------+
# Customizing webpage themes using `bslib`
Bootstrap themes can be used for both webpages and shiny apps. The default is Bootstrap 4. You can change color schemes and other aesthetic parameters easily with `bslib` just by changing a few parameters in the yml part of the Rmarkdown file.