r language n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
R Language PowerPoint Presentation
Download Presentation
R Language

Loading in 2 Seconds...

play fullscreen
1 / 16

R Language - PowerPoint PPT Presentation


  • 128 Views
  • Uploaded on

R Language. What is R? Variables in R Summary of data Box plot Histogram Using Help in R. What is R ?. R is a free, cross-platform, open-source statistical analysis language and program.  Many statistical functions are already built in. Variables. Numeric > a = 49 > sqrt(a)

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'R Language' - dean


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide2

What is R?

  • Variables in R
  • Summary of data
  • Box plot
  • Histogram
  • Using Help in R
what is r
What is R ?
  • R is a free, cross-platform, open-source statistical analysis language and program. 
  • Many statistical functions are already built in
variables
Variables
  • Numeric

> a = 49

> sqrt(a)

[1] 7

  • String

> a = "The dog ate my homework"

> sub("dog","cat",a)

[1] "The cat ate my homework“

  • Logical

> a = (1+1==3)

> a

[1] FALSE

slide5

vector: an ordered collection of data of the same type

> a = c(1,2,3)

To examine the contents of the variable a

>a

[1] 1 2 3

> a*2

[1] 2 4 6

> a[2]

[1] 2

slide6

list: an ordered collection of data of arbitrary types.

> d = list(name="john",age=28,married=F)

> d$name

[1] "john“

> d$age

[1] 28

slide7
Mean
  • Dataset:

> x=c(0,4,15, 1, 6, 3, 20, 5, 8, 1, 3)

>y= 1:6

>y

[1] 1 2 3 4 5 6

  • The Mean

> mean(x)

[1] 6

OR

> sum(x)/length(x)

[1] 6

median
Median
  • Sort the dataset if it is not sorted

>sort(x)

[1] 0 1 1 3 3 4 5 6 8 15 20

  • The Median

> median(x)

[1] 4

> median(y)

[1] 3.5

quantiles
Quantiles
  • Q1

> quantile(x,0.25)

25%

2

  • Q3

> quantile(x,0.75)

75%

7

  • Quantiles

> quantile(x,c(0,0.25,0.5,0.75,1))

0% 25% 50% 75% 100%

0 2 4 7 20

five number summary
Five Number Summary

> summary(x)

Min. 1st Qu. Median Mean 3rd Qu. Max.

0 2 4 6 7 20

the spread of the data set
The Spread of the Data Set
  • Range

> range(x)

[1] 0 20

  • IQR

> IQR(x)

[1] 5

boxplot
Boxplot
  • Standard Boxplot

> boxplot(x,range=0)

  • Modified Boxplot

> boxplot(x)

histogram
Histogram

> hist(x)

  • Adding a title

> hist(x,main=“Weight Gain”)

  • Adding Axis labels

>hist(x , main=“Weight Gain”,xlab=“Weight Gain”, ylab =“Frequency”)

  • Change the color

>hist(x , main=“Weight Gain”,xlab=“Weight Gain”, ylab =“Frequency”, col=“blue”)

read csv
Read CSV

> mydata=read.csv("dataset.csv")

> mydata

Age Income

1 10 0

2 25 35000

3 43 75000

4 32 55000

5 70 25000

6 19 20000

7 5 0

8 21 20000

9 35 60000

10 24 30000

how to use help in r
How to use help in R?
  • R has a very good help system built in.
  • If you know which function you want help with simply use ?_______ with the function in the blank.
  • Ex: ?hist.
  • If you don’t know which function to use, then use help.search(“_______”).
  • Ex: help.search(“histogram”).
activity
Activity
  • Using R language, Answer question 4 from the Tutorial.
  • Export the resulted graphs.