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.

using InteractiveUtils # Only required for notebook rendering
versioninfo()
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 4 default, 0 interactive, 2 GC (on 4 virtual cores)
Environment:
  JULIA_NUM_THREADS = auto
  JULIA_LOAD_PATH = @:@stdlib
using Pkg
Pkg.status()
Status `~/Documents/Repos/JuliaEpiHandbook/Project.toml`
  [336ed68f] CSV v0.10.14
⌃ [13f3f980] CairoMakie v0.12.2
  [a93c6f00] DataFrames v1.6.1
  [1313f7d8] DataFramesMeta v0.15.2
  [634d3b9d] DrWatson v2.15.0
⌃ [e9467ef8] GLMakie v0.10.2
  [cd3eb016] HTTP v1.10.8
⌃ [7073ff75] IJulia v1.24.2
⌃ [c3a54625] JET v0.9.2
  [0f8b85d8] JSON3 v1.14.0
  [98e50ef6] JuliaFormatter v1.0.56
  [70703baa] JuliaSyntax v0.4.8
⌃ [295af30f] Revise v3.5.14
  [db9b398d] Serde v3.1.0
  [8ae5e7a9] TidierFiles v0.1.1
⌃ [0656b61e] GLFW_jll v3.3.9+0
Info Packages marked with ⌃ have new versions available and may be upgradable.

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.