1.4 Notation throughout this book

When in sentences, the names of R packages, functions, and variable names are printed with mono-spaced font, e.g.: tidyverse, mean(), lifeExp.

Otherwise, R code lives in the grey areas known as ‘code chunks’. Lines of R output start with a double ## - this will be numbers or text that R gives us after executing the code. When printing this output, R also adds a counter at the beginning of every new line, look at the numbers in the square brackets [] below:

##  [1] 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
## [16] 1016 1017

Remember, lines of R code that start with # are called comments. We already introduced comments as notes about the R code earlier in this chapter (Section 1.1 “Help, what’s a script?”), however, there is a second use case for comments. When you make R code a comment, by adding a # in front of it, it gets ‘commented out’. For example, let’s say your R script does two things, prints number from 1 to 4, and then numbers from 1001 to 1004:

## [1] 1 2 3 4
## [1] 1001 1002 1003 1004

If you decide to ‘comment out’ the printing of big numbers, the code will look like this:

## [1] 1 2 3 4

You may even want to add another real comment to explain why the latter was commented out:

You could of course delete the line(s) altogether, but commenting out is useful if you might want to comment the lines back in later by removing the # from the beginning of the line. Commenting in only works for R code, text comments within a code chunk or script (e.g., “# Now we’re printing bigger numbers:”) must always start with a # or you will get an error.

Keyboard Shortcut for commenting out/commenting in multiple lines at a time: Control+Shift+C
(On a Mac, both Control or Command work)

Finally, we use bold to highglight a new term we are introducing for the first time. The same term will not be bold in future occurances.