Sumários
Session 11
2 Novembro 2022, 11:00 • Nuno Miguel Brites
10 Simulation 59
10.1 The set.seed()function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
10.2 Random numbers and probability distributions . . . . . . . . . . . . . . . . . . . . . . . . 60
10.3 Monte Carlo integration (example) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
11 Linear models 65
11.1 Fitting models: the lm()function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Session 10
26 Outubro 2022, 11:00 • Nuno Miguel Brites
9 The dplyr package 51
9.1 The pipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
9.2 Single table verbs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Session 9
19 Outubro 2022, 11:00 • Nuno Miguel Brites
4 CONTENTS
7.4 Xapply() family: a substitute to loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8 Manipulating data 45
8.1 Manipulating data vs. working with data . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
8.2 tapply(), aggregate() and by(): Apply a function within a group . . . . . . . . . . . . . . 46
8.3 Tabulating data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Session 8
12 Outubro 2022, 09:30 • Nuno Miguel Brites
6 Functions 33
6.1 Simple Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.2 Default arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.3 Vectorial functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
6.4 Integrals and derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
6.5 Simple plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
6.6 Function source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7 Loops and flow control 37
7.1 Loops with for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7.2 Flow control: if and if else statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
7.3 While loop example . . .