Upcoming SlideShare
×

# Introduction to R

339
-1

Published on

Introduction to R

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
339
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
18
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Introduction to R

1. 1. Introduction to R• http://cran.r-project.org/• The Comprehensive R Archive Network• The Base System• The idea of Packages• Open source Implementation of S• Commercial implementation is S Plus -Sujoy Bhattacharya
2. 2. • Default Prompt is ‘>’• setwd("C:/Documents and Settings/USER/My Documents")• getwd()• ?(plot)• R is case sensitive
3. 3. • Objects in R: variables, arrays of numbers, character strings, functions .• function c()• assignment operator (‘<-’)• Create an object z such that: x=1 to 20, y= 30 to 35, z= concatenation of x and y
4. 4. • common arithmetic functions: log, exp, sin, cos, tan, sqrt• range()• mean(y)=sum(y)/ length(y)• sort(object): elements are arranged in increasing order
5. 5. • seq(from=5, to=50)• seq(-4, 4, by=.1)• z<- rep(x, times=4)• rep(x, each=4)
6. 6. Logical Vectors• values :TRUE, FALSE, and NA• <, <=, >, >=, ==(equality) != ( inequality)• z <- x > 20• z1 & z2 (intersection)• z1 | z2 (union)• !z negation of z
7. 7. • NA and NaN• Do 0/0 and z<- c(2,5,NA)• Operations on NA are NA• Do z<- c(1:100,NA)• t<- 100*z
8. 8. • Arrays: dim(z) <- c(3,2,2)• z[1,1,1]• While entering data match length• z[1,1,]• z <- array(1:20, dim=c(4,5))• Z <- array(data_vector, dim_vector)
9. 9. • object <- array(data_vector, dim_vector)• dd <- array(data=c(1:125),c(5,5,5))• cbind() and rbind()• z<- cbind(c(1:10),c(1:5))• transpose of an array: t(z)• Matrix product : x %*% y
10. 10. • x<- array(data=c(1:6),c(2,3))• Matrix inversion :solve(z)• x<- cbind(1, y, z): y,z must have equal rows.
11. 11. • read.csv(file.choose(), header=T)• reg1 <- lm(y ~ x1 + x2, data = nse)• plot(object)• residuals(object)• plot(x, y)
12. 12. R communities• www.r-project.org• www.r-forge.r-project.org• www.rstudio.com
1. #### A particular slide catching your eye?

Clipping is a handy way to collect important slides you want to go back to later.