Statistics in R lectures
Lecture 1:
R Studio:
You should use it to do all your data processing, no spreadsheet editing
In your paper, you need to cite R, not R Studio
Functions are (file.path (Argument), mean (Argument), getwd (), setwd(Argument) etc)
Arguments are separated by commas
→ Mean (c(1,2,3,4,8,10)
?function: Help page opens
Directory: source location of files
Change source location by using setwd (“insert new location”)
Script: Upper left part of the screen, used to write the functions.
Console: Bottom left of the screen, to paste the functions into, through the script.
Environment: workspace on the right (upper) side of the screen, set of all objects and
variables you have created during an R session.
Lecture 2:
sep = “\t” for tab-delimited
sep = “,” of “;”
pseudocode
list of phrases/sentences that explain a
Objects/variables
Objects cannot be values, but are created or named by an arrow <-
variables can be values
Vectors: sets of values
- Classes: numeric (numbers), characters (characters), logical (true/false)
- All of the values of a column need to be of the same class.
Character vectors
- A string of characters
- identified by ‘this’ or “this”
Packages: install.packages(‘tidyverse’) → installing once
library(tidyverse) → opening/reloading every session
packages are not the same as functions or libraries,
packages contain libraries
libraries contain functions
some packages have the same name as their function