Lab1: Introduction to R


Getting Started with R

Click on the R icon

If no R icon, go to Start and then All Programs to find R

To quit R:

> q()

What does it ask you? What does this mean?

For R HELP, for example to get help about the function runif ,

> help(runif)

For R HELP in html format

If you go to Help on the R toolbar and select R language (html), you will get the html version of help.


Example 1: Let the games begin.

Generate a sample of 100 N(0,1) random variables.

> help(rnorm)

> temp <- rnorm(100)

What is in the object temp?

What is the length of the oject temp?

Make a informative plot of temp?

If this were part of a homework problem, you might want to copy and paste the R code and plot into a Word Document?
Try it!

Note: To copy and paste from the graphics window,
Right click on the mouse and select Copy as metafile, then Paste.


Example 2: Binomial Test

> help(binom.test)

Class example: Binom(25,0.4). If B=15, what do you conclude?

> binom.test(15,25,0.4, alternative="greater")

Calculate P(B >= 15) in R. For the signficance level, P(B >= 14)?

What about CI's for this test? (see help function)


Intro to R Part I:

Here is first introduction to R: ISU

At the bottom of the page is how to get the "An Introduction to R"


Intro to R Part II:

Try going through the following Intro. Lessons. The # sign is a comment, so you can copy and paste.

  • R vectors, lists and functions
  • R arithmetic and logical operators
  • R simple functions
  • R univariate random variable generators