misc/our-style.md

Code

Code lives in the code directory in files named according to the chapter they are in, e.g. 01-venn.R. The code does not have to be self-standing: it can depend on code run previously in the chapter.

# Filename: filename.R (2018-02-06)
# Aim: What should the script achieve
#
# Author(s): Robin Lovelace, Jakub Nowosad, Jannes Muenchow
#
#**********************************************************
# CONTENTS-------------------------------------------------
#**********************************************************
#
# 1. ATTACH PACKAGES AND DATA
# 2. DATA EXPLORATION
#
#**********************************************************
# 1 ATTACH PACKAGES AND DATA-------------------------------
#**********************************************************

# attach packages
library(sf)
# attach data
nc = st_read(system.file("shape/nc.shp", package = "sf"))

#**********************************************************
# 2 DATA EXPLORATION---------------------------------------
#**********************************************************

Comments

Comment your code unless obvious because the aim is teaching. Use capital first letter for full-line comment.

# Create object x
x = 1:9

Do not capitalise comment for end-of-line comment

y = x^2 # square of x

Text

Captions

Captions should not contain any markdown characters, e.g. * or *. References in captions also should be avoided.

Figures

Names of the figures should contain a chapter number, e.g. 04-world-map.png or 11-population-animation.gif.

File names

References

References are added using the markdown syntax [@refname] from the .bib files in this repo. The package citr can be used to automate citation search and entry. Use Zotero to add references to the geocompr at zotero.org rather than changing .bib files directly. The citation key format used is [auth:lower]_[veryshorttitle:lower]_[year] using zotero-better-bibtex.



Robinlovelace/geocompr documentation built on June 14, 2025, 1:21 p.m.