R_supplement_to_FPSR_through_ch9

R_supplement_to_FPSR_through_ch9 - R Supplement to The...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: R Supplement to The Fundamentals of Political Science Research Stephen R. Haptonstahl As of May 3, 2011 2 Contents Introduction 5 How to Use This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1 Getting Started 7 1.1 Installing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.2 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.3 More Functions: Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.4 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2 Structure 9 2.1 Saving Your Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.1.1 Running Source Code from the Internal Editor . . . . . . . . . . . . . . . . . . . . . . 9 2.1.2 Save the Source, Not the Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.1.3 Dont Save Your Workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.2 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.3 Data Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3 Looping 13 3.1 Our Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.2 The Hard Way: Copy, Paste, Modify (Mess Up, Give Up) . . . . . . . . . . . . . . . . . . . . 13 3.3 The Easier Way: Do Once, Generalize, for () . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.4 Talking to Yourself: Comments and cat () . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.5 Keeping it Neat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 4 Randomness 17 4.1 Finite Sample Spaces: Flipping a Coin, Rolling a Die . . . . . . . . . . . . . . . . . . . . . . . 17 4.2 Infinite Sample Spaces: Throwing a Dart, Waiting for a Table . . . . . . . . . . . . . . . . . . 18 4.2.1 Draws from a Normal distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.2.2 Draws from a Poisson distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 5 Getting Data 21 5.1 Direct Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 5.1.1 read.delim () . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 5.1.2 read.dtaread....
View Full Document

Page1 / 48

R_supplement_to_FPSR_through_ch9 - R Supplement to The...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online