script — the file that the code is stored in. This is a permanent record of the commands that you want R to execute.
console — the screen that shows what commands have just been executed. The calculations and values that result from running the code end up here.
syntax — the “grammar” of the programming language. The specifics of how you write a command for it to be understood as something for R to execute.
comments — lines of code in the script file that are not treated as commands by R. Anything after a ‘#’ will be ignored by R, so you can write notes in plain English to remind yourself and collaborators what the commands are doing. These are absolutely CRITICAL for writing legible code.
variables — named objects in R. We’ll see a lot of different kinds of variables (e.g. integers, real numbers, vectors, matrices, character strings). They do not alter the original data or variables that are used to derive them, and they are named by the user.
functions -- the workhorse of R. Does 3 things: takes in arguments, does something to those arguments, returns ONE thing.
arguments -- variables that are passed to a function so the function can perform some operation on them.
What does it do: exponentiates x
What does it return: a single number representing the exponentiation of x
log(x, base = exp(1))
Arguments: x, base (default is exp(1))
What does it do: calculates the log of x given the base
What does it return: a single number representing the log of x given the base