################### #----- Lab 0 -----# ################### # You can use R as a calculator 1+2 (1+2*(3-4)) / 2 # parentheses are highlighted # Nothing is saved ls() # But if we assign it to an object x <- (1+2) / 3 # Now, x is saved ls() # Delete it rm(x) # Now x is not recognized x # Assign a value to x, y, z x <- 1 y <- 2 z <- 3 # Perform calculations with objects x + y # R recognizes capital letters! x X # See what your working directory is getwd() # Set it to whatever you want, e.g. your Desktop (replace '...' in the code below) setwd("C:/.../Desktop") # Save your history for later use (with name "history_name") savehistory("C:/.../history_name.R") # Load it again if you want loadhistory("C:/.../history_name.R") # Delete every saved object rm(list = ls()) # Get help with a function (3 ways) ?mean # short for help(mean) ??mean # short for help.search("mean"): searches the help pages of all installed packages apropos("mean") # searches in the loaded packages (can be shown via search()) # Create your first plot (a Normal(0,1) of course!) xx <- seq(-4, 4, length.out = 1000) plot(xx, dnorm(xx, 0, 1), type = "l") plot(1:10, 1:10) dev.new() plot(1:5, 1:5) dev.off() # Quit RStudio q()