Skip to Main Content
Introduction to Probability
book

Introduction to Probability

by Joseph K. Blitzstein, Jessica Hwang
September 2015
Beginner content levelBeginner
596 pages
18h 33m
English
CRC Press
Content preview from Introduction to Probability

Appendix B

R

B.1 Vectors

Command

What it does

c(1,1,0,2.7,3.1)

creates the vector (1,1, 0, 2.7, 3.1)

1:100

creates the vector (1, 2,... , 100)

(1:100)^3

creates the vector (13, 23,. .. , 1003)

rep(0,50)

creates the vector (0, 0,... , 0) of length 50

seq(0,99,3)

creates the vector (0, 3, 6, 9,... , 99)

v[5]

5th entry of vector v (index starts at 1)

v[-5]

all but the 5th entry of v

v[c(3,1,4)]

3rd, 1st, 4th entries of vector v

v[v>2]

entries of v that exceed 2

which(v>2)

indices of v such that entry exceeds 2

which(v==7)

indices of v such that entry equals 7

min(v)

minimum of v

max(v)

maximum of v

which.max(v)

indices where max(v) is achieved

sum(v)

sum of the entries in v

cumsum(v)

cumulative sums of the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Introduction to Probability.

Introduction to Probability.

N. Balakrishnan, Markos V. Koutras, Konstadinos G. Politis

Publisher Resources

ISBN: 9781466575578