How to plot distribution of relative frequncy using ggplot2?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to plot distribution of relative frequncy using ggplot2?

vod vos
Hello everyone,

How to plot distribution of relative frequncy using ggplot2 ? The example figure is in the attachment.

If we have data:

aa<- c(1,5,10,20,50,40,50,60,70,80,90,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000)

bb<- c(8,16,30,24,39,54,40,68,72,62,122,80,181,259,275,380,320,434,479,587,626,648,738,766,793,851,871,957,1001,960)

aabbdiff<- aa-bb

aabb<- data.frame(aa, bb, aabbdiff)

library(ggplot2)

ggplot(aabb, aes(aabbdiff)) + geom_histogram()

The above code line did not show what I want, how to draw the figure like in the attachment?

Thanks.



______________________________________________
[hidden email] 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.

geom.png (98K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to plot distribution of relative frequncy using ggplot2?

Bert Gunter-2
Is this homework?

(We don't do homework here).

Also, this looks pretty basic. Have you gone through any ggplot
tutorials? -- the web and the Rstudio site have many.


-- Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sat, Feb 25, 2017 at 8:21 AM, vod vos <[hidden email]> wrote:

> Hello everyone,
>
> How to plot distribution of relative frequncy using ggplot2 ? The example figure is in the attachment.
>
> If we have data:
>
> aa<- c(1,5,10,20,50,40,50,60,70,80,90,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000)
>
> bb<- c(8,16,30,24,39,54,40,68,72,62,122,80,181,259,275,380,320,434,479,587,626,648,738,766,793,851,871,957,1001,960)
>
> aabbdiff<- aa-bb
>
> aabb<- data.frame(aa, bb, aabbdiff)
>
> library(ggplot2)
>
> ggplot(aabb, aes(aabbdiff)) + geom_histogram()
>
> The above code line did not show what I want, how to draw the figure like in the attachment?
>
> Thanks.
>
>
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.