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.
Generate a sample of 100 normal random variables, N(0,1).
> help(rnorm)
> rnorm(100) What happens with the numbers?
It would be better to:
> 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.
We will need 3 functions to play poker. I have written these functions, so the help files are not in R, yet.
They are not too complicated. The 3 functions are:
There are 2 ways to get these functions for your very own.
> source("http://www.rohan.sdsu.edu/~babailey/stat550/cards.r")
> source("http://www.rohan.sdsu.edu/~babailey/stat550/rperm.r")
> source("http://www.rohan.sdsu.edu/~babailey/stat550/poker.r")
For practice, generate 1 hand of 5 card poker.
IMPORTANT If you want to reproduce your results, you will have to
set the seed of the random number generator.
There is an R function set.seed
To use it,
> set.seed(1)
> poker(draw=5, hand=1)
How can you draw the same hand again?
Here is first introduction to R: ISU
At the bottom of the page is how to get the "An Introduction to R"
If you want even more practice:
Try going through the following Intro. Lessons. The # sign is a comment, so
you can copy and paste.