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 ļ¬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!ā¢
!
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( )!ā¦
!
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 ā¢
for help on a speciļ¬c 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

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 ļ¬rst element of list one to the ā¢
ļ¬rst 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!ā¢
!
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!ā¢
!
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