intro to r r is a free version of s-plus r is a free version of s-plus can be used interactively but...

7
Intro to R Intro to R R is a free version of S-plus R is a free version of S-plus Can be used interactively but Can be used interactively but script or syntax files are script or syntax files are commonly used to record and commonly used to record and reproduce steps. reproduce steps. R consists of a set of “base” R consists of a set of “base” routines and a large library of routines and a large library of user supplied “packages” user supplied “packages”

Upload: milton-bradford

Post on 28-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Intro to R R is a free version of S-plus R is a free version of S-plus Can be used interactively but script or syntax files are commonly used to record

Intro to RIntro to R

R is a free version of S-plusR is a free version of S-plus Can be used interactively but script or Can be used interactively but script or

syntax files are commonly used to syntax files are commonly used to record and reproduce steps.record and reproduce steps.

R consists of a set of “base” routines R consists of a set of “base” routines and a large library of user supplied and a large library of user supplied “packages”“packages”

Page 2: Intro to R R is a free version of S-plus R is a free version of S-plus Can be used interactively but script or syntax files are commonly used to record

R documentationR documentation

Basic manual for RBasic manual for R Venables, W. N. and Ripley, B. D., 4th edn Venables, W. N. and Ripley, B. D., 4th edn

2002. Modern Applied Statistics with S. 2002. Modern Applied Statistics with S. Springer, NYSpringer, NY

Free documentation on CRANFree documentation on CRAN CRAN user help listserveCRAN user help listserve

Searchable mail archivesSearchable mail archives GoogleGoogle

Page 3: Intro to R R is a free version of S-plus R is a free version of S-plus Can be used interactively but script or syntax files are commonly used to record

Getting HelpGetting Help

> help(command)> help(command) >?(command)>?(command) > help.search("matrix")> help.search("matrix")

lists all functions whose help pages have a title or lists all functions whose help pages have a title or alias in which the text string “matrix” appearsalias in which the text string “matrix” appears

> apropos(“matrix”)> apropos(“matrix”) lists all function names that include the text “matrix”lists all function names that include the text “matrix”

Page 4: Intro to R R is a free version of S-plus R is a free version of S-plus Can be used interactively but script or syntax files are commonly used to record

R objectsR objects

R is an object-oriented programming R is an object-oriented programming languagelanguage

R functions operate on objectsR functions operate on objects e.g., vectors, matrices, arrays, lists, data e.g., vectors, matrices, arrays, lists, data

framesframes Basic analysis are typically conducted Basic analysis are typically conducted

by working with by working with DATA FRAMESDATA FRAMES Generally try to avoid looping Generally try to avoid looping

Page 5: Intro to R R is a free version of S-plus R is a free version of S-plus Can be used interactively but script or syntax files are commonly used to record

Data EntryData Entry

I generally use excel, save as a “csv” I generally use excel, save as a “csv” format, and then read into Rformat, and then read into R

R can also read in other data R can also read in other data structures such as SPSS, SAS, SYSTAT, structures such as SPSS, SAS, SYSTAT, ect...ect...

Page 6: Intro to R R is a free version of S-plus R is a free version of S-plus Can be used interactively but script or syntax files are commonly used to record

Learning RLearning R

Best way is to just start using itBest way is to just start using it Keep one of the reference cards Keep one of the reference cards

handyhandy Keep a file where you store examples Keep a file where you store examples

of handy code/tricks so you can find of handy code/tricks so you can find them laterthem later

Page 7: Intro to R R is a free version of S-plus R is a free version of S-plus Can be used interactively but script or syntax files are commonly used to record

Let's start with a simple exampleLet's start with a simple example