[R] cdf in R give probability of random variable

Martin Maechler maechler at stat.math.ethz.ch
Sat Oct 22 16:59:08 CEST 2016


>>>>> peter dalgaard <pdalgd at gmail.com>
>>>>>     on Fri, 21 Oct 2016 22:10:22 +0200 writes:

    >> On 21 Oct 2016, at 20:23 , peter dalgaard
    >> <pdalgd at gmail.com> wrote:
    >> 
    >> In both cases it works out nicer if you do
    >> 
    >> names(px) <- x
    >> barplot(px)

    > Um, unless of course you want the cdf as a step function,
    > in which case check the help page for plot for possible
    > values of the type= argument.

and if it is not homework, (or even then ;-)  just use
	
  plot(ecdf(x))


Martin Maechler, ETH Zurich



More information about the R-help mailing list