[1] 1 645 329
An integrated development environment is software that makes coding easier
Tip
Now, you can just quit and restart RStudio if something goes wrong! You can also go to Session -> Restart R to clear your session.
mean()
, lm()
, table()
, etc.base
, stats
, graphics
, etc.{ggplot2}
, {dplyr}
, {data.table}
, {survival}
, etc. 1“You only have to buy the book once, but you have to go get it out of the bookshelf every time you want to read it.”
Several days later…
install.packages
, packages are downloaded from CRAN (The Comprehensive R Archive Network)
<-
to store objects in the environmentI call this the “assignment arrow”
Now vals
holds those values
Warning
No assignment arrow means that the object will be printed to the console (and lost forever!)
We can retrieve those values by running just the name of the object
[1] 1 645 329
We can also perform operations on them using functions like mean()
[1] 325
If we want to keep the result of that operation, we need to use <-
again
We could also create a character vector:
[1] "dog" "cat" "rhino"
Or a logical vector:
[1] TRUE FALSE FALSE
Tip
We’ll see more options as we go along!
We created vectors with the c()
function (c
stands for concatenate)
We could also create a matrix of values with the matrix()
function:
[,1] [,2] [,3]
[1,] 234 12 183
[2,] 7456 654 753
The numbers in square brackets are indices, which we can use to pull out values:
[1] "cat"
We can pull out rows or columns from matrices:
[1] 7456 654 753
[1] 234 7456