Lab 3 - Statistics 20
2016. Vivian Lew. All Rights Reserved.
Due July 9, 2016 before 6pm via upload to CCLE
Please submit both a .Rmd file and compiled HTML (or PDF) file to prove that your graphics compiled
correctly.
Introduction
I used basic R graphics

Advanced R
Environments
Cheat Sheet
Created by: Arianne Colton and Sean Chen
Environment Basics
Environment Data structure (with two
components below) that powers lexical scoping
Search Path
Search path mechanism to look up objects, particularly functions

Handling and Processing Strings in R
Gaston Sanchez
www.gastonsanchez.com
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported
License (CC BY-NC-SA 3.0) http:/creativecommons.org/licenses/by-nc-sa/3.0/ In short:

R Markdown Cheat Sheet
learn more at rmarkdown.rstudio.com
1. Workflow
R Markdown is a format for writing reproducible, dynamic reports with R. Use it to
embed R code and results into slideshows, pdfs, html documents, Word files and more. To make a report

2
Simple Usage of Traditional Graphics
Chapter preview
This chapter introduces the main high-level plotting functions in the
traditional graphics system. These are the functions used to produce
complete plots such as scatterplots, histograms, and boxplots

Week 2 Preparation
Stat 20 Summer 2016
June 27, 2016
Please try to get through as much of this as possible before 10:50am on Wednesday. If you can read ahead,
then lecture will be easy for you. There are also Week 2 notes and suggested readings to help yo

Lab 1 - Statistics 20
2016. Vivian Lew. All Rights Reserved.
Due June 25, 2016 before 6pm via upload to CCLE
The only acceptable format for your lab assignments is R Markdown (an .Rmd file) which is created within
RStudio and a compiled HTML file. R Markd

Lab 2 - Statistics 20
2016. Vivian Lew. All Rights Reserved.
Due July 2, 2016 before 6pm via upload to CCLE
The only acceptable format for your lab assignments is R Markdown (an .Rmd file) which is created within
RStudio with a compiled HTML or PDF file.

Week 4 Preparation
Stat 20 Summer 2016
July 11 & 13, 2016
Please try to get through as much of this as possible before 10:50am on Wednesday. If you can read ahead,
then lecture will be easy for you. There are also Week 4 notes and suggested readings to he

R Data Editor Versus Spreadsheets
The R data editor can be convenient for inspecting a data frame or a matrix or
maybe for editing a couple of values, but I dont recommend using it for doing
serious work. If you have a lot of data to enter, I recommend us

8
Symbols and Environments
So far, weve danced around the concept of environments without explicitly defining
them. Every symbol in R is defined within a specific environment. An environment
is an R object that contains the set of symbols available in a g

Week 5 The Apply Family, Sampling, and Basic Function
Programming
Repetitive Actions
Stat 20 Summer 2016
July 18 & July 20, 2016
Background
One of Rs strengths is the ability to perform an action repeatedly. We can see this in three areas this week:
1.
2.

Lab 6 - Statistics 20
206. Vivian Lew. All Rights Reserved.
Due Saturday, July 30, 2016 by 6pm via upload to CCLE
If you have received full credit on your other 5 labs, there is no extra (except work) to be gained from
completing this lab. If you have not

Lab 6 alternative - Statistics 20
2016. Vivian Lew. All Rights Reserved.
Due July 30, 2016 before 6pm via upload to CCLE
Please submit both a .Rmd file and compiled HTML file to prove that your graphics compiled correctly. I
did not finish programming fun

Chapter 5
Exploratory Data Analysis
5.1 Introduction
Exploratory data analysis is the process by which a person manipulates data
with the goal of learning about general patterns or tendencies and finding
specific occurrences that deviate from the general

Lab 4 - Statistics 20
2016. Vivian Lew. All Rights Reserved.
Due July 16, 2016 before 6pm via upload to CCLE
Please submit both a .Rmd file and an .html file that proves to us that your .Rmd file compiled correctly.
1 Variable Creation and Transformation

Lab 5
Stat 20 Summer 2016
Due Saturday July 23, 2016 by 6pm via upload to CCLE
Part 1: Generating Random Samples
A. Different small random normal samples from the standard normal
Set a seed and create four samples, each one of size 36, from a standard nor

Base R
Cheat Sheet
Getting Help
Accessing the help files
?mean
Get help of a particular function.
help.search(weighted mean)
Search the help files for a word or phrase.
help(package = dplyr)
Find help for a package.
More about an object
str(iris)
Get a su

3
MATR ICES AND AR R AYS
A matrix is a vector with two additional
attributes: the number of rows and the
number of columns. Since matrices are vectors, they also have modes, such as numeric and
character. (On the other hand, vectors are not onecolumn or o

2: '\s' is an unrecognized escape in a character string
3: unrecognized escapes removed from "C:\Data\sample-data.csv"
4: In file(file, "rt") :
cannot open file 'C:Datasample-data.csv': No such file or directory
R escapes every character that follows a ba

The save function is very flexible and can be used in many different ways. You can
save multiple objects, save to files or connections, and save in a variety of formats:
save(., list =, file =, ascii =, version = , envir =,
compress =, eval.promises = , p

Lecture 2
Fall 2016
STATS 20 Introduction to Statistical Programming with R
Maria Cha
Fall 2016 Maria Cha
Before we start.
Check your attendance on sign sheets.
Download files in Lecture 2 on Week 1 from
CCLE
Fall 2016 Maria Cha
Last lecture
Introducti

STATS 20 Fall 2016
Homework 1 Due Sep 30th, 11:59pm
*Upload in pdf format ONLY(lose 1 points for other format)
* Show all R commands that you used.
1. Find a function, which does Chi-square test. Attach a help page in R for the
function. (5)

Week 5 The Apply Family, Sampling, and Basic Function
Programming
Repetitive Actions
Stat 20 Summer 2016
July 18 & July 20, 2016
Background
One of Rs strengths is the ability to perform an action repeatedly. We can see this in three (optional 4th) areas t

CHAPTER 8
Probability
Introduction
Probability theory is the foundation of statistics, and R has plenty of machinery for
working with probability, probability distributions, and random variables. The recipes
in this chapter show you how to calculate proba

CHAPTER 3
Bar Graphs
Bar graphs are perhaps the most commonly used kind of data visualization. Theyre
typically used to display numeric values (on the y-axis), for different categories (on the
x-axis). For example, a bar graph would be good for showing th

3
A Short R Tutorial
This chapter contains a short tutorial of R with a lot of examples.
If youve never used R before, this is a great time to start it up and try playing with
it. Theres no better way to learn something than by trying it yourself. You can

3
Customizing Traditional Graphics
Chapter preview
It is very often the case that a high-level plotting function does not
produce exactly the final result that is desired. This chapter describes
low-level traditional functions that are useful for controll

Week 4 IrRitations/Necessary Evils
but also Basic Statistics with R
Stat 20 Summer 2016
July 11 and 13
Factors
Factors are variables in R which take on a limited number of different values, typically they are called
categorical" variables.
We use factor