Presentation is loading. Please wait.

Presentation is loading. Please wait.

Training on R-language Mārtiņš Liberts Central Statistical Bureau of Latvia.

Similar presentations


Presentation on theme: "Training on R-language Mārtiņš Liberts Central Statistical Bureau of Latvia."— Presentation transcript:

1 Training on R-language Mārtiņš Liberts Central Statistical Bureau of Latvia

2 Outline Introduction with R Practical examples with R Sampling package Practical examples with Sampling package

3 R — a language and environment R (www.R-project.org) is an advanced statistical computing system with very high quality graphics that is freely available for most computing platforms. The S language is often the vehicle of choice for research in statistical methodology and R provides a free software route to participation in that activity.

4 R R is being developed for the Unix, Windows and Mac families of operating systems. It is a system available as source code (at www.R- project.org) that compiles on almost all current Unix and Linux systems, and has binary versions for the major Linux distributions, FreeBSD, MacOS X and Windows. It is distributed under GPL2 (the “GNU Public Licence”). The core system is fairly small but can be extended by packages, several ‘recommended’ ones ship with R and about 300 (and growing) are available from CRAN (CRAN.R-project.org and mirrors).

5 Work with R Console R prompt > Input Output Scripts Input Workspace Storage of the objects created during work sessions

6 Work with R

7 Running commands from console Type in the commands and execute by Enter Running commands from script Select commands for running and execute by Ctrl+R It is possible to select only the part of command and execute this part Whole line where the cursor is positioned will be executed if nothing is selected

8 Work with R 2+4 pi sin(pi/2) S=0 for (i in 1:10) S=S+i S

9 Help in R help.start() ?sin help.search("sin")

10 R objects Numbers and vectors Matrices Lists Data frames Logical values Missing values Factors The function is.*

11 Numbers and vectors a=5 Y=c(1,3,6,8) Y+a Y[3]

12 Arithmetic operators and functions Operators: + - * / ^ %*% %/% % : Functions: abs exp gamma lgamma log log10 sign sqrt sin cos tan sinh asin asinh max min range length sum prod sort order rank rev cumsum cumprod var mean...

13 Generating sequences of numbers Using : 1:5 5:1 Using seq seq(from=0,to=3,length=6) Using rep rep(1,5)

14 matrix, data.frames matrix M=cbind(1:5,6:10,11:15) M[1,2] M[1,] M[,3] M[1,2] data.frame treeframe=data.frame (diameter=c(10, 15, 20, 25), height=c(1.5,1.6,1.2,2.1)) treeframe[,1] treeframe$diameter

15 Logical values Logical operators == != > >= < <= & | ! Examples X=seq(from=0,to=10,length=21) X<5 X[X<5] treeframe[treeframe$diameter<20,2]

16 Packages CRAN.R-project.org library(foreign) read.spss

17 The sampling package Version 0.3 Date 2006-04-12 Title Sampling survey Author Yves Till é yves.tille@unine.ch Alina Matei alina.matei@unine.chyves.tille@unine.chalina.matei@unine.ch Maintainer Yves Till é yves.tille@unine.chyves.tille@unine.ch Description The sampling package contains a set of tools to select and to calibrate samples. Depends MASS, lpSolve License GPL version 2 or later.

18 Functions regressionestimator boundedregressionestimator checkcalibration Other functions


Download ppt "Training on R-language Mārtiņš Liberts Central Statistical Bureau of Latvia."

Similar presentations


Ads by Google