CSC
Week 5 Feb 1.pdf

# Week 5 Feb 1.pdf - Week 5 Feb 1 Wednesday 11:30 AM What...

• Notes
• 2

This preview shows pages 1–2. Sign up to view the full content.

> rep(c(8,1,2), length=10) #repeats vector until 10 elements [1] 8 1 2 8 1 2 8 1 2 8 What we've learned so far: > rep(c(8,1,2), each=3) [1] 8 8 8 1 1 1 2 2 2 We can now do this more "neatly" using each > 1:20 [1] 1 2 3 4 ……… 20 > 20:1 [1] 20 19 18 …… 1 We know: >seq(1,2, by=0.1) [1] 1.0 1.1 1.2 …….. 1.9 2.0 >seq(1.1, by=0.01, length=13) repeat +0.01 13 times [1] 1.1 1.11 1.12 …… 1.22 Sequence vectors allow you to choose how much the numbers differ by (not just 1) Sequence Vectors >c(5) [1] 5 >c(1:5) >[1] 1 2 3 4 5 >rep(c(5), 3) [1] 5 5 5 NOT HERE: You should only use c when you want to combine single values or vectors into a bigger vector Arranging a vector into a 2D array >matrix(3, nrow=2, ncol=2) [,1][,2] [1,] 3 3 [2,] 3 3 >matrix (1:6, nrow=2, ncol=3, byrow=TRUE) [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 Matrix function that takes a vector as data You can assign matrices to variables Variables containing matrices can be multiplied as MATRICES (%*%) or ELEMENT-by-element (*) Matrices do not have to be treated as linear algebra - they can just be a way to display your data

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.
• Winter '17
• Radford M. Neal

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern