STATS 13 Lecture Notes - Lecture 1: Working Directory, Rstudio, Umber
Course CodeSTATS 13
This preview shows half of the first page. to view the full 3 pages of the document.
Lab 1 Notes!
Required package: mosaic!
# creates a comment so that text is not read as R command!•
can be added at the beginning of the line or at the end of a command!•
ex. # comment is not evaluated by R!•
2 +3 #this will be evaluated by R!•
 5 !
if this is the output then  is the index that tells us that the ﬁrst entry or element of the output •
is the umber 5!
when there are output vectors with more than one entry this will be important!•
the default folder or directory from which R reads and writes data!•
you can get/set the working directory from the menu bar in R or R studio!•
getwd() #returns the current working directory!•
stewd("~/Desktop") #changes working directory!•
run the quit function !•
Installing and Loading R Packages!
a package in R is a collection of functions !•
to load and access an installed package in R, use library() function and input name of the •
package to use without quotations!
the library() function will get an error if you load a package that has not be installed !•
install.packages() #input the name of the package you want to install in single or double •
packages only need to be installed once per computer!•
access functions and data from it using library() function !•
use function of dataset from given package, use library() every time you open a new R console!•
help on a built in function in R, use ? followed by the name of the function ro apply the help() •
ex. ?mean or help(mean) #same thing as ?!◦
if you don't know the name of the function, search with a double question mark ?? followed by •
the search term, apply the help.search() or use the search bar in the help tab in the bottom
right pane of RStudio!
ex. ??regression or help.search("regression")!◦
the single question mark will search for functions in the package that are currently loaded !•
the double question mark will search for any documentation in all of the packages installed on •
for help on a speciﬁc package that is already installed, used help in the library() function!•
You're Reading a Preview
Unlock to view full version