[R] Is it possible to create such graph - Which packages can come handy?
MacQueen, Don
macqueen1 at llnl.gov
Thu Dec 22 01:55:15 CET 2016
It's certainly possible, and you don't need any packages to do it; you can do it all in base R.
You can use the findInterval() function to identify which points are in which ranges. Here's an example:
> x <- runif(16, 20, 30)
> xc <- seq(20, 30, by=2)
> xc
[1] 20 22 24 26 28 30
> findInterval(x, xc)
[1] 4 5 4 5 2 2 2 5 2 1 1 3 4 1 1 5
Then within each interval calculate the mean and standard deviation, use those as input to the dnorm() function to calculate the bell curves. It'll take some tweaking to deal with the fact that you want the bell curves oriented vertically. The smoothing curve can be created with the supsmu() function, among others. There are various details that could make the whole thing tricky to get exactly as you want it. But it's certainly possible.
-Don
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 12/20/16, 7:04 AM, "R-help on behalf of Narendra Modi" <r-help-bounces at r-project.org on behalf of bjpmodi2016 at gmail.com> wrote:
Hello Gurus,
I intend to build attached reference graph in R(r.png). Could you give
me some ideas on how it can be done, if at all possible?
Basically, I would like to build a Histogram along Y axis for
different respective X axis ranges.
As shown in the input.png file, there is a value of EUR for every Lw,
a simple X-Y scatter plot.
Now, what if I build ranges of x axis values, i.e 2000-4000,
4000-6000, 6000-8000 etc and analyze the histograms of Y axis values
for those ranges?
Thanks!
More information about the R-help
mailing list