Class Notes (1,100,000)
US (480,000)
UCLA (10,000)
STATS (200)
Lecture 1

STATS 13 Lecture Notes - Lecture 1: Working Directory, Rstudio, Umber


Department
Statistics
Course Code
STATS 13
Professor
Tsiang, Mike
Lecture
1

This preview shows half of the first page. to view the full 3 pages of the document.
Lab 1 Notes!
Required package: mosaic!
!
Getting Started!
Commenting!
# 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!
!
Index !
[1] 5 !
if this is the output then [1] is the index that tells us that the first entry or element of the output
is the umber 5!
when there are output vectors with more than one entry this will be important!
!
Working Directories!
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!
!
Quitting R!
run the quit function !
q( )!
!
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
quotations !
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!
!
Getting Help!
help on a built in function in R, use ? followed by the name of the function ro apply the help()
function!
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
your computer!
for help on a specific package that is already installed, used help in the library() function!
library(help="mosaic")!
You're Reading a Preview

Unlock to view full version