[R] Brand new To R

(Ted Harding) Ted.Harding at manchester.ac.uk
Sun Sep 13 21:00:01 CEST 2009


On 13-Sep-09 16:47:07, czarjosh wrote:
> 
> I am trying to learn R right now. I came from minitab and wanted
> to learn something a bit more robust. I am trying to figure out
> some simple probability to measures but I do not know the commands.
> I am using > OSX. Are there resources for figuring out simple events?
> 
> If I have data distributed as Normal(5,4) and I wanted to know what
> the probability of P(<6) would be this, I cannot quite figute out how
> to work this out.

For each of the common distributions, there is a group of R functions
giving the density/point probability, the cumulative probability,
the inverse of this (i.e. whiat x corresponds to a given probability),
and also a function for sampling randomly from it.

In the 'help' files, these four are groups togther in a single file.

For the Normal distribution, these functions are

  dnorm
  pnorm
  qnorm
  rnorm
So, if you enter ther command

  ?pnorm

you will get a summary for all of them. Similarly if you enter
?pnorm or ?qnorm or ?rnorm. For your query, the probability that
X < 6 is simply pnorm(q=6,mean=5,sd=4), which you can abbreviate to
pnorm(6,5,4):

  pnorm(q=6,mean=5,sd=4)
  # [1] 0.5987063
  pnorm(6,5,4)
  # [1] 0.5987063

the reason they are equaivlent as given is that when the arguments
are not named, R identifies them by position, so that in "pnorm(6,5,4)"
it is assumed that q=6, mean=5, sd=4. If you prefer to give them
in a different order, then you will have to name them:

  pnorm(4,5,6)
  # [1] 0.4338162
  pnorm(sd=4,mean=5,q=6)
  # [1] 0.5987063

Similarly you will find dchisq, pchisq, qchisq, rchisq for the
chi-squared distribution, dt, pt, qt, rt for the Student t distribution,
df, pf, qf, rf for the F distribution, dbinom etc. for the Binomial,
dpois etc. for the Poisson, and many others!

Hoping this helps.
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 13-Sep-09                                       Time: 19:59:58
------------------------------ XFMail ------------------------------




More information about the R-help mailing list