Reserved Symbols and Functions

In class we covered essentially all of Chapter 2 of An Introduction to R.

We began with symbols or characters reserved in R, e.g., arithmetic operators such as:


Then moved to one of the more important reserved symbols: #.

# R will ignore all code, words, instructions after the hashtag
# We will use the # to annotate code!
# Like so:

(16 - 9)^2 # this line of code should evaluate to 49

Logical operators.

> # greater than
< # less than
>= # greater or equal than
<= # less or equal than
== # equal to
!= # not equal to
& # and
| # or 

Finally, we discussed simple functions and how to use them. For example, consider the round() function.

# Suppose we wanted to round the number 3.1234 to the second digit. 
# We would invoke the round() function to do so.

round(x = 3.1234, digits = 2)

Inside of the parentheses of functions each function accepts inputs and the user can set various arguments of the function. We set the input argument x equal to 3.1234 and the digits argument equal to 2, so as to round our input 3.1234 to the second digit. Arguments are separated by commas. If you are unsure as to what arguments the user can set and manipulate you should consider the ? operator which when combined with a function name will call up the functions help page. On the help page the function’s arguments and defaults are listed and described.