An Introduction to R: Examples for Actuaries - toolkit

0 downloads 119 Views 447KB Size Report
Jan 28, 2006 - created from any spreadsheet or database application. An example of this is included below. Note: A chara
An Introduction to R: Examples for Actuaries

Nigel De Silva 28 Jan 2006 version 0.1

Contents 1 Introduction.................................................................................................................1 1.1 What is R?............................................................................................................1 1.2 R Packages...........................................................................................................2 1.3 Online Resources..................................................................................................2 2 Some Preliminaries.....................................................................................................3 2.1 Starting R in Windows.........................................................................................3 2.2 Getting help with functions and features..............................................................4 2.3 R )

12

2.7

Examples Series The following series of examples will provide simple introductions into possible uses for R. Functions will be introduced with little commentary regarding the syntax, so don’t forget to use the help options. Commands will be taken from the script editor window rather than the command line window, as in this section. As they will not contain the “>” prompt, you can copy the commands directly from this text into R and run the examples yourself. Some examples rely on )

0.0 -1.0 -0.5

sin (x)

0.5

1.0

The Sine Function

0

2

4

6

8 x

Try finding a root of this equation using the uniroot function.

14

10

12

3.2

, xlab="Body Weight (kg)", ylab="Brain Weight (g)") identify(body, brain, rownames(mammals)) # Left click on , xlab="log(Body Weight)", ylab="log(Brain Weight)") identify(lbody, lbrain, rownames(mammals))

17

mammals.lm