Appendix D — Code topics
This appendix gathers together links to parts of the book that cover various code topics in R:
- Comments: Note 2.2 and Note 7.2.
- Variables: Section 4.6.
- Types of values in R: Section 7.3.
- Strings — values containing text: Section 7.4.
- Randomness from your computer: Section 2.2.
- Types of brackets in R: Note 4.2.
- vector length: Section 6.5.
- Squaring values and vectors: Section 16.7.1.
- Indexing into vectors with integers: Section 6.6.
- Selecting multiple elements from vectors with slicing: Section 10.2.
- Introducing functions: Section 5.7.
- Named arguments to functions: Section 5.8.
- Functions and methods: ?nte-functions-methods.
- Ranges (continuous sequences) of integers: Section 5.9.
- Advanced ranges (for example, using floating point values), using
seq
: Note 21.6. - The absolute function (
abs
) to convert all values to positive: Note 16.3. - Repeating elements of a vector with
rep
: Section 7.6} for
loops: Section 6.6.2.if
statements: Section 8.10.- Finding number of repeats using
tabulate
: Section 11.6 - Combining Boolean vectors with
&
: Section 10.6 - Testing whether all elements of a vector are the same using
all
: Note 13.5 - Plotting and histograms (and histogram bins and bin edges): Section 12.15.2.
- Shuffling vectors with
sample
: Section 8.14. - Choosing values at random with
sample
: Section 5.10. - Counting
TRUE
values withsum
: Section 5.13. - Making vectors by random resampling with
sample
: Section 5.11. - Building strings with
paste
: Section 21.1.1. - What is an operator?: Note 23.2.
- Logical operators — or(
|
), and(&
): Section 23.1. - Concatenating vectors: Section 12.15.1.
- The Comma-Separated-Values (CSV) file format for data tables: Section 16.1.1.