This looks like homework, but doing it in R might not be, so I'll give you the benefit of doubt...
> On 21 Oct 2016, at 18:30 , Ragia . <ragi...@hotmail.com> wrote: > > > Dear Grooup > > kindly > > how can I plot these graphs in R.. > > > Suppose that X is a discrete random variable with P(X = 0) = .25, P(X = 1) = > .125, P(X = 2) = .125, and P(X = 3) = .5. Graph the frequency function and > the cumulative distribution function of X. > > > > my solution was: > > x=c(0,1,3) > px=c(.25,.125,.5) > plot( x,px ,type="h" ) # to plot the frequency , is it correct > You forgot X=2 in there (check the sum). > how to plot the cdf? > cumsum() is your friend. In both cases it works out nicer if you do names(px) <- x barplot(px) -pd > [[alternative HTML version deleted]] Notice that plain text posting is strongly preferred in here. HTML messes up code badly sometimes. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd....@cbs.dk Priv: pda...@gmail.com ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.