An introduction to R - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

An introduction to R

Description:

State of the art: many statistical researchers provide their methods as R packages ... vector: an ordered collection of data of the same type. a = c(1,2,3) a[3] a*2 ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 12
Provided by: xuel
Category:

less

Transcript and Presenter's Notes

Title: An introduction to R


1
An introduction to R
  • Xueli Liu
  • STA4502/5507
  • October 1, 2007

2
R and statistics
Packaging a crucial infrastructure to
efficiently produce, load and keep consistent
software libraries from (many) different sources
/ authors Statistics most packages deal with
statistics and data analysis State of the art
many statistical researchers provide their
methods as R packages
3
R as a calculator
  • log2(32)
  • sqrt(2)
  • seq(0, 5, length6)
  • plot(sin(seq(0, 2pi, length100)))
  • q()-quit R session

4
Variables
gt a 49 gt sqrt(a) gt a "The dog ate my
homework" gt sub("dog","cat",a) 1 "The cat ate
my homework gt a (113) gt a 1 FALSE
numeric
character string
logical
5
vectors, matrices and arrays
  • vector an ordered collection of data of the same
    type
  • a c(1,2,3)
  • a3
  • gt a2
  • matrix a rectangular table of data of the same
    type
  • b matrix(999, 10,4)
  • b

6
Branching
if (logical expression) statements else
alternative statements else branch is optional
7
Loops
for(i in 110) print(ii) i1 while(ilt10)
print(ii) iisqrt(i)
8
Importing and exporting data
  • To deal with rectangular tables in the form of
    tab-delimited text files.
  • gt x read.delim(filename.txt)
  • also read.table, read.csv
  • write.table(x, filex.txt, sep\t)
  • setwd change directory

9
Getting help
Details about a specific command gt?
t.test help.search(keyword)
10
Preparing Computer Output for Printing
  • Save command as a script file for later use
  • copy-and-paste that portion of the R commands and
    output of interest into an editor of some kind
    Include only those parts that you need
    cut-and-paste as you go along.
  • Command we need so far
  • ?shapiro.test
  • ?wilcox.test
  • ?ks.test
  • ?rank

11
Web sites
Reference card for basic functions
http//cran.r-project.org/doc/contrib/refcard.pdf
Downloading and help search www.r-project.org cr
an.r-project.org http//www.stat.ufl.edu/xueli/st
a6329/sta6329.html
Write a Comment
User Comments (0)
About PowerShow.com