Study Guides (390,000)
US (220,000)
UCLA (3,000)
STATS (50)
Study Guide

STATS 13 Study Guide - Fall 2019, Comprehensive Final Exam Notes - Null Hypothesis, Standard Deviation, Dependent And Independent Variables


Department
Statistics
Course Code
STATS 13
Professor
Tsiang, Mike
Study Guide
Final

This preview shows pages 1-3. to view the full 98 pages of the document.
STATS 13

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

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")!
find more resources at oneclass.com
find more resources at oneclass.com
You're Reading a Preview

Unlock to view full version

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

!
Basic Objects in R!
Object Assignment!
all objects are called the workspace or the global environment!
to save objects/functions/etc into R's current workspace, use assignment operator <- !
names of objects/functions/etc can contain letters, numbers, or underscores and must start
with a letter.!
case sensitive!
the name of the object you want to make goes on the left of the <- !
<- is an arrow pointing to the left to signify that you're assigning the output of the code on
the right to the object name on the left!
= can also be used to assignment but it is recommended to use <- since the direction of the
assignment is clear !
!
Vectors !
most fundamental object in R is a vector, ordered collection of values!
entries of vectors are called elements of compounds!
single values or scalars are just vector with a single element!
ex. numbers <- c(1,2,3)!
create a numeric vector objet called numbers that contains the numbers 1 to 5!
schools <-c("UCLA","UC Berkeley", "USC"!
character vector object called schools that contains the names of schools!
c() is used to create both vectors!
once you make an object you can use the print function to print contents of an object!
print(numbers)!
if the vector is numeric, we can do math on it !
numbers*2!
we can use standard arithmetic operators !
we can also use square brackets to create subsets of our data!
if you type schools [2] you will get the second element from the schools vector !
cbind(numbers, school) will create a matrix that corresponds the first element of list one to the
first element of list two!
!
Object Classes!
vector, matrices, and data frames are three common object classes!
matrices and data frame are similar to tables of data with rows and columns, but every value in
a matrix must be the same type (all numeric values)!
data frames can contain several types of data!
!
Reading Data Into Studio!
R needs to be told which folder to get data!
Rstudio -- go to session > set working directory > choose directory!
then select the folder the data is saved in and create a new data object using the syntax!
object_name <- read.csv (file= "filename.csv")!
object_name <- read.csv(file.choose( ) )!
!
Summarizing Data (one variable)!
functions show how quantitative data is distributed!
summary()!
mean()!
find more resources at oneclass.com
find more resources at oneclass.com
You're Reading a Preview

Unlock to view full version