Chapter 4 Figures, tables, hosting GitBook

This section is going to focus including figures and creating tables

Summary of methdological procedure for (a).... and (b)....

Figure 4.1: Summary of methdological procedure for (a)…. and (b)….

4.1 Including figures and tables

4.1.1 Figures

To include the figure above use the code:

knitr::include_graphics(here::here('general_images','example_flow.png'))

within a code chunk. In the chunk options you can specify the width and figure captions e.g. 

out.width="100pt", fig.cap="Summary of methdological procedure for (a).... and (b)....".

However, if you do show the code with echo=TRUE then you can’t specify the out.width.

For making flow diagrams have a look at:

  1. Lucidchart
  2. Draw.io

4.1.2 Tables

For creating tables i’d suggest creating either an excel file or .csv and then reading the data into R and using the kabble package to format it how you wish. The example below is from the abbreviations section

library(tidyverse)
library(knitr)
library(kableExtra)
library(readxl)
library(fs)
library(here)

#read in data
read_excel(here("tables", "abbreviations.xlsx"))%>%
  arrange(Term) %>% # i.e. alphabetical order by Term
  # booktab = T gives us a pretty APA-ish table
  knitr::kable(booktabs = TRUE)%>% 
  kable_styling(position = "center")%>%
  # any specifc row changes you want
    row_spec(.,
  row=0,
  bold = TRUE)
Term Abbreviation
Digital Elevation Model DEM
Digital Surface Model DSM
Digital Terrain Model DTM

You do loads of things with kabble including adding small visulisations within the table - consult the documentation for more info.

If in doubt, keep it simple

other useful arguments for tables:

  • column_spec(2, width = "9cm") = set column width

  • kable(timeline,longtable = T....= allow the table to go over multiple pages

For example…

read_excel(here("tables", "policy.xlsx"))%>%
  mutate_all(~ replace_na(.x, "")) %>%
  # booktab = T gives us a pretty APA-ish table
  knitr::kable(longtable = T, booktabs = T, 
               caption = 'Relevant influential international, metropolitan and local UHI and urban expansion policies, strategies and assessments (with publication date) referred to in this paper. * Denotes documents that lack specific UHI related policy but recognise the value of maintaining vegetation.')%>% 
  kable_styling(position = "center", full_width = T)%>%
  # any specifc row changes you want
    row_spec(.,
  row=c(0,1,8, 18),
  bold = TRUE)%>%
  column_spec(1, width = "14cm")%>%
  row_spec(c(1, 8, 18), hline_after = T)
Table 4.1: Relevant influential international, metropolitan and local UHI and urban expansion policies, strategies and assessments (with publication date) referred to in this paper. * Denotes documents that lack specific UHI related policy but recognise the value of maintaining vegetation.
Policy
International
United Nations The World Cities in 2016 (2016)
United Nations New Urban Agenda (2017)
ARUP City Resilience Framework (2015)
United Nations International Strategy for Disaster Reduction Sendai Framework (2015)
Universal Sustainable Development Goals (2015)
Biological Diversity, Cities and Biodiversity Outlook (2012)
Metropolitan
AECOM Australia, Economic Assessment of the Urban Heat Island Effect, Melbourne (2012)
The Spatial Development Strategy For Greater London (2017)
Western Australia Planning Commission, Perth and Peel (3.5?) million (2015)
City of Johannesburg Metropolitan Municipality, Spatial Development Framework 2040 (2016)
Western Australian Planning Commission, Directions 2031 and beyond: metropolitan planning beyond the horizon (2010)
Western Australian Planning Commission, Development Control Policy 2.3 Public Open Space in Residential Areas (2002)
Plan For The Metropolitan Region Perth And Fremantle (1955)
Singapore Government, Open Space Provision (2011)
Western Australian Planning Commission, Metropolitan Region Scheme Text (2006)
Local
USA Environmental Protection Agency, Reducing Urban Heat Islands Compendium of Strategies Trees and Vegetation (2008)
USA Environmental Protection Agency, Reducing Urban Heat Islands Compendium of Strategies Urban Heat Island Basics (2008)
USA Environmental Protection Agency, Reducing Urban Heat Islands, Compendium of Strategies Heat Island Reduction Activities (2008)
City of Stirling, Stirling Urban Forest Community Consultation (2017)
City of Fremantle, One Planet Fremantle Strategy 2014/2015 - 2019/2020, 1–12 (2014)
Metropolitan Redevelopment Authority, Subiaco Redevelopment Scheme (2013)
Metropolitan Redevelopment Authority, Subiaco Redevelopment Scheme 2 (2017)
City of Bayswater, Urban Forest Strategy (2017)
City of Perth, Urban Forest Plan 2016-2036 (2006)
City of Fremantle, City of Fremantle Urban Forest Plan (2017)
City of Fremantle, Annual Budget 2016-17 (2016)
City of Wanneroo, Street Tree Policy (2016)*
City of Subiaco, Plant Pathogen Management Plan(2015)*

Note if you see the caption in the .pdf version it goes off the side of the page — this is the reason why you don’t show code in a .pdf. If you ever had to you could just seperate the string into sections and at the start use paste("hello","this","is","a","string", sep=" ")

Now remember to cross reference this table, it would be…Table \@ref(tab:kable), giving Table 4.1

4.2 Hosting the book

You will need to create a new GitHub repository to host your book online using GitHub pages — like the example is. GitHub pages takes a load of .html files and makes a website.

To do so you need to set up a few things

  1. Go to the _bookdown.yml file and make sue that that you have this line of code: output_dir: docs (it should be there)
  2. In the same file make sure your book_filename doesn’t have any spaces use - or _ e.g. CASA-Thesis
  3. Go to the _output.yml file and change the edit argument to YOURREPO/edit/main/%s, here it’s https://github.com/andrewmaclachlan/CASA-MSc-thesis/edit/main/%s
  4. Build your book locally, close the preview window
  5. Save, stage changes, commit and then push to GitHub
  6. On your GitHub repository > settings > GitHub pages > select the source as main and the folder as docs
  7. Make sure you build your .pdf and then your gitbook for the latest .pdf to be a download option on the website.