R code blocks
Throughout this book you will see blocks with R code followed by its output, if the given code produced any, like in the following example:
[1] -0.519608392 -1.543506573 -0.280458149 0.001209828 -0.021665130
[6] 2.099836362 0.178011703 -0.180836596 0.645022621 -1.782333794
[11] 0.404781279 -1.089094415 -0.482640950 -0.007777161 -1.211965390
[16] 0.472652973 -0.166609529 -0.895589112 -2.463060078 -0.296914050
If you mouse over the input code box, a clickable “Copy to clipboard” button appears on the top right of the box allowing you to copy & paste into an R console or file.
Notice that R adds numbers in brackets in the beginning of each row. This happens when R prints the contents of a vector. The number is the integer index of the first element in that row. Therefore, the first one is always [1] and the number of the subsequent rows depends on how many elements fit in each line. If the output is a single element, it will still have [1] in front of it.
If we enclose the assignment operation of a variable in parentheses, the object is printed to the console. Therefore, this:
is equivalent to this:
WebR executable code blocks
WebR is a new technology that allows running R in the browser. As the content of the book is being updated and extended, you will see executable blocks like the one below. Edit the code and click Run Code to execute it.
Fonts
This site uses Fira Code to display source code. Like a number of other font families, it supports a number character ligatures that make code look prettier / easier to read. Note that even though ligations make some symbol combinations look like a single symbol, they are still separate characters.
For example, the assignment operator, <-, is still written using the characters < and -.
Themes
The light/dark mode switch is located in the top left of the page. Note that most figures will appear with inverted colors when the dark theme is selected, i.e. the true colors are displayed with the light theme only.
Made with Quarto
This book was created using Quarto. The first version of the book had been built using bookdown.