library(tidyverse)HTML files do not use templates, but can have the styles configured within the YAML. HTMLs are interactive documents, and are particularly flexible. We cover some basic options here.
Table of contents: We can add a table of contents with toc: true below, and also specify that it remains viewable (“floats”) as you scroll, with toc_float: true.
Themes: We can refer to some pre-made themes, which come from a Bootswatch theme library. In the below example we use cerulean. Other options include: journal, flatly, darkly, readable, spacelab, united, cosmo, lumen, paper, sandstone, simplex, and yeti, Bootswatch Themes
Highlight: Configuring this changes the look of highlighted text (e.g. code within chunks that are shown). Supported styles include default, tango, pygments, kate, monochrome, espresso, zenburn, haddock, breezedark, and textmate.
package # remotes::install_github(“gadenbuie/cleanrmd”) cleanrmd::html_document_clean: theme : NULL
A hash symbol in a text portion of a R Markdown script creates a heading. This is different than in a chunk of R code in the script, in which a hash symbol is a mechanism to comment/annotate/de-activate, as in a normal R script.
Use asterisks (*) to created a bullets list. Finish the previous sentence, enter two spaces, Enter/Return twice, and then start your bullets. Include a space between the asterisk and your bullet text. After each bullet enter two spaces and then Enter/Return. Sub-bullets work the same way but are indented. Numbers work the same way but instead of an asterisk, write 1), 2), etc. Below is how your R Markdown script text might look.
Here are my bullets (there are two spaces after this colon):
Uniquely in R Markdown, to initiate a new line, enter *two spaces** at the end of the previous line and then Enter/Return.
Surround your normal text with these character to change how it appears in the output.
There is no simple mechanism to change the color of text in R Markdown. One work-around, IF your output is an HTML file, is to add an HTML line into the markdown text. The below HTML code will print a line of text in bold red.
DANGER: This is a warning.
-You can include images in your R Markdown one of two ways:
-If the above does not work, try using knitr::include_graphics() knitr::include_graphics(“path/to/image.png”)
-(remember, your file path could be written using the here package) knitr::include_graphics(here::here(“path”, “to”, “image.png”))
Some notes about the contents of the curly brackets { }:
The investment_annual_summary dataset provides a summary
of the dollars in millions provided to each region for each fiscal year,
from 2012 to 2018.
## # A tibble: 42 x 3
## fiscal_year region dollars_in_millions
## <dbl> <chr> <dbl>
## 1 2012 East Asia and the Pacific 2548
## 2 2012 Europe and Central Asia 2915
## 3 2012 Latin America and the Caribbean 3680
## 4 2012 Middle East and North Africa 2210
## 5 2012 South Asia 1312
## 6 2012 Sub-Saharan Africa 2733
## 7 2013 East Asia and the Pacific 2873
## 8 2013 Europe and Central Asia 3261
## 9 2013 Latin America and the Caribbean 4822
## 10 2013 Middle East and North Africa 2038
## # ... with 32 more rows
Figure 1.1 The Investment Annual Summary for each region for 2012 to 2018
The investment_services_projects dataset provides
information about each investment project from 2012 to 2018. Information
listed includes the project name, company name, sector, project status,
and investment amounts.
## # A tibble: 90 x 13
## date_disclosed country ifc_country_code sector project_name
## <dttm> <chr> <chr> <chr> <chr>
## 1 2018-12-14 00:00:00 Brazil BRA Funds Vinci Capit~
## 2 2018-11-13 00:00:00 Brazil BRA Telecommunications~ Cabo Teleco~
## 3 2018-10-24 00:00:00 Brazil BRA Financial Institut~ Frida
## 4 2018-10-18 00:00:00 Brazil BRA Financial Institut~ Golden Grass
## 5 2018-07-18 00:00:00 Brazil BRA Health and Educati~ Cruzeiro Gr~
## 6 2018-07-05 00:00:00 Brazil BRA Financial Institut~ Contabilizei
## 7 2018-04-27 00:00:00 Brazil BRA Agribusiness and F~ Bauducco Gr~
## 8 2018-04-11 00:00:00 Brazil BRA Agribusiness and F~ Sao Manoel
## 9 2018-03-14 00:00:00 Brazil BRA Infrastructure Gas Natural~
## 10 2018-02-07 00:00:00 Brazil BRA Financial Institut~ WCS Bansicr~
## # ... with 80 more rows, and 8 more variables: project_number <dbl>,
## # company_name <chr>, status <chr>,
## # ifc_investment_for_risk_management_million_usd <dbl>,
## # ifc_investment_for_guarantee_million_usd <dbl>,
## # ifc_investment_for_loan_million_usd <dbl>,
## # ifc_investment_for_equity_million_usd <dbl>,
## # total_ifc_investment_as_approved_by_board_million_usd <dbl>
## Warning: Removed 8 rows containing missing values (geom_point).
Figure 1.2 The Investment Services Projects in Brazil from 2012 to 2018
## Warning: Removed 4 rows containing missing values (geom_point).
Figure 1.2 The Investment Services Projects in Brazil from 2012 to 2018
The total investment amount for all projects in Brazil in the 2018 fiscal year was 951.18 million dollars.
2.2 Comment out text
You can “comment out” R Markdown text just as you can use the “#” to comment out a line of R code in an R chunk.