Introduction to R - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Introduction to R

Description:

Introduction to R A. Di Bucchianico Types of statistical software command-line software requires knowledge of syntax of commands reproducible results through scripts ... – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 16
Provided by: DiBucch2
Category:

less

Transcript and Presenter's Notes

Title: Introduction to R


1
Introduction to R
  • A. Di Bucchianico

2
Types of statistical software
  • command-line software
  • requires knowledge of syntax of commands
  • reproducible results through scripts
  • detailed analyses possible
  • GUI-based software
  • does not require knowledge of commands
  • not reproducible actions
  • hybrid types (both command-line and GUI)

3
Well-known statistical software
  • SAS
  • SPSS
  • Minitab
  • Statgraphics
  • S-Plus
  • R

4
R
  • free
  • language almost the same as S
  • maintained by top quality experts
  • available on all platforms
  • continuous improvement
  • Available through www.r-project.org

5
Contents
  • Basic operations
  • Data creation I/O
  • Component extraction
  • Plots
  • Basic statistics
  • Libraries
  • Regression analysis
  • Survival analysis

6
Basic operations
  • assignment operation a lt- 2sqrt(5)
  • help function
  • help(pnorm)
  • help.search(normal distribution)
  • probability functions
  • d (density) dgamma(x,n,?)
  • p (probabilitycdf) pweibull(x,3,2)
  • q (quantile) qnorm(0.95)
  • r (random numbers) rexp(10,?)

7
Data creation I/O
  • create
  • vectors c(1,2,3)
  • matrices matrix(c(1,2,3,4,5,6),2,3,byrowT)
    (2rows)
  • list
  • patterns
  • (1,2,3) 13
  • seq (1,2,3) seq(1,3,by1)
  • working directories and files
  • setwd
  • getwd
  • attach
  • read data
  • from file read.table(file.txt,headerTRUE)
  • from web read.data.url

8
Component extraction
  • dr, rth row of object d
  • d,c cth column of object d
  • dr,c entry in row r and column c of object d
  • length(d) length of d
  • ddlt20 extract all elements of d that are
    smaller than 20
  • dage extract column age from object d

9
Plots
  • plot both 1D and 2D plots
  • hist histogram
  • qqnorm normal probability plot
    (quantile-quantile plot)
  • Save graphics by choosing File -gt Save as

10
Basic statistics
  • summary
  • mean
  • stdev
  • t.test
  • boxplot

11
Packages
  • specialized functions available through packages
    and libraries
  • in Windows interface choose Packages -gt Load
    Packages
  • examples of packages
  • qcc (quality control)
  • survival

12
Functions
  • Analyses that have to be performed often can be
    put in the form of functions
  • Example simple lt- function(data,mean0,alpha0.05
    )
  • hist(data),t.test(data,conf.levelalpha,mumean,a
    lternativetwo-sided)
  • simple(data,4) uses the default value 0.05 and
    test the null hypothesis mu4.

13
Regression analysis
  • general command lm (linear model)
  • requires data to be available in the form of a
    data frame
  • more general than matrix because columns need not
    have same length)
  • use command data.frame for conversion
  • other types of regression also possible (see also
    dedicated packages)

14
Survival analysis
  • through library Surv of survival
  • Cox proportional hazards coxph

15
Useful web sites
  • www.r-project.org
  • http//cran.r-project.org/doc/contrib/Short-refcar
    d.pdf
  • http//www.uni-muenster.de/ZIV/Mitarbeiter/BennoSu
    eselbeck/s-html/shelp.html
  • http//www.maths.lth.se/help/R/
  • http//www.mas.ncl.ac.uk/ndjw1/teaching/sim/R-int
    ro.html
  • http//stats.math.uni-augsburg.de/JGR/
  • http//socserv.mcmaster.ca/jfox/Misc/Rcmdr/index.h
    tml
Write a Comment
User Comments (0)
About PowerShow.com