Keywords, Code, and Other Formatting

Author
Affiliation

Pennsylvania State University

Published

May 20, 2023

General Formatting

Throughout the book, you’ll see some keywords, code, and other points that I’ll try to delineate with the following formatting:

Note

This will be a note, and will be used to highlight important points, or to provide additional information.

Tip

This will be used to highlight a useful tip.

Warning

This will provide a warning that you may get an unexpected result if you’re not careful.

  • code will be used to highlight code.
  • {package} will be used to denote a specific package, e.g., {DataFrames} denotes the {DataFrames} package.
  • package.function() will be used to denote a function that is part of a specific package, e.g., DataFrames.subset() denotes the subset() function from the {DataFrames} package. Some languages use a different convention, such as package::function() in R, but I will use the package.function() syntax listed above as this is how you would use a function in Julia.
  • keywords will be used to highlight keywords and phrases, e.g., Git or GitHub.
    • actions will also be highlighted in this way, e.g., commits or pushed being the result of the code git commit or git push
  • files will be used to highlight file names, e.g., README.md or LICENSE.
  • italics will be used for emphasis in certain circumstances, e.g., signifying a question from an interactive terminal command.

Packages

Throughout this book, I will use a number of packages to help with the analysis and visualization of data. For each section, I will provide a list of the packages used in a particular set of analyses at the top of the page. The Julia language has an excellent package manager that makes it easy to install and use packages, and also share projects and collaborate with others without running into issues regarding dependencies that often plagues other languages. In the next section, I will walk through the process of getting started with Julia, and therefore, the process of installing packages, but below you can see the full list of packages and the installed version of Julia used in this book.

versioninfo()
Julia Version 1.9.2
Commit e4ee485e909 (2023-07-05 09:39 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
  Threads: 5 on 4 virtual cores
Environment:
  JULIA_NUM_THREADS = auto
using Pkg
Pkg.status()
Status `~/Documents/Repos/JuliaEpiHandbook/Project.toml`
  [336ed68f] CSV v0.10.11
  [13f3f980] CairoMakie v0.10.7
  [a93c6f00] DataFrames v1.6.1
  [1313f7d8] DataFramesMeta v0.14.0
  [634d3b9d] DrWatson v2.12.7
  [7073ff75] IJulia v1.24.2
  [c3a54625] JET v0.8.9
  [98e50ef6] JuliaFormatter v1.0.35
  [70703baa] JuliaSyntax v0.4.6
  [295af30f] Revise v3.5.3

Code Style

There are many different ways to write code, and many different styles. But, in the interest of consistency and ease of collaboration, I would strongly recommend you use the {JuliaFormatter} package to format your code according to a specific style guide. In this book, I will use a lightly modified version of the Blue style guide, and you can see the specific changes to the default style in the .JuliaFormatter.toml file in the root directory of this book’s GitHub repository. In the next section, I will discuss how you can use the {JuliaFormatter} package to format your code.