Lecture 6
Xiaotong Suo
Todays agenda
Some common func7ons, which are really
useful
Regular expressions- working with text
Conver7ng one variable to another
as.numeric
as.character
as.matrix
as.data.frame
Order

Lecture 7
Xiaotong Suo
Warm-up
Lets do some exercises!
Paste func;on
How to paste a vector of strings together?
Metaharacters
Parenthesis are typically used to limit the
scope of the | metacharacter.

Lecture 5
Xiaotong Suo
Todays Agenda
Control structures
Regression Analysis
Control structure con9nued
Apply func9on
Some9mes we want to apply a func9on to each
individual row or column of a matrix, or to each

Lecture 4
Xiaotong Suo
Homework 1
Ques7on 3
Todays agenda
Data input/output
Graphics
Data input/output
R can write matrix and data frames to le using the
func7on write.table. And read data from le using

CME/Stats 195
Lecture 2
Xiaotong Suo
xiaotong@stanford.edu
More logis>cs
Knowledge of some calculus
Course enrollment
Five candies rule
Apologies for the coursework
Oce hour?
Ques>ons from last lecture
#: comme

Lecture 3
Xiaotong Suo
Logis1cs
HW 1 due on Wednesday before the class. No
late homework will be accepted. Note that
you have to get at least 60% on each
homework to pass this class.
Todays agenda
Matr

Welcome to CME 195
Introduc4on to R
Xiaotong Suo
Course overview
Two parts of this short course:
R basics
R in sta4s4cs
Course prerequisite
No programming course required. So if you
already took

Homework 2
Xiaotong
April 10, 2015
Due: April 17th, Friday
Your name: (10%)
1
Problem 1
(40%) Using only multiplication, summation, matrix or vector manipulations,
the power function, and the function choose, write some R code to check that
n
(1)i
i=0
n
i

Homework 3
Xiaotong Suo
April 21, 2015
Your name is:
1
Problem 1
(5%) X is a 10 10 data frame. What does the following code do?
x[abs(x[,7]< 1, ]
x[which(x[,10]>0)&(x[,10] <9),]
2
Problem 2
(15%)You have a vector of string:
txt = c(a,z1,b2,c4,z10,z3)
You

Homework 1
Your name: (20 %)
Due: April 8th, Wednesday before class.
1. If we have two integers m1 = 3, m2 = 2. How to check if m1 is equal to m2? (5 %)
2. Create two vectors, m, n. where m = [