R - Lab 1 Flashcards
text
Makes a comment.
Use comments frequently
3+5
Addition
8
2*3
Multiplication
6
4^2
Exponents
16
exp(1.5)
Calculates e to the 1.5 power
x=exp(1.5)
Makes variable ‘x’ equal to exp(1.5)
Doesn’t report anything
Recalling a variable
Type the variable
Ex: If x=exp(1.5)
x
4.481689
log(x)
Natural log of x
What happens if you write incomplete code?
Example:
x=exp(1.5
R will give a ‘+’ on the next line
- Either finish (type ‘)’ ) or press escape
How to scroll through history of commands?
Up and down arrows
How to bring up the help file for a command?
help([command])
So:
help(exp)
How to search for functions that include a certain word?
??’[text]’
??’exponentiate’
What letter must you put in front of parenthesis to create a vector (list of values)?
c
Example vector
x=c(4,5,6)
In vectors:
x[2]
Tells us the 2nd value of x.
If
x=c(4,5,6)
Then
x[2]= 5