Skip to content

Histogram

8 messages · Steven Kennedy, nandini_bn, Rolf Turner +2 more

#
Hello ,
I am trying to create a histogram in order to compare between two groups and
would like it to be similar to the figure attached. How can I generate this
using R ?


Thank you,
Nandini http://r.789695.n4.nabble.com/file/n3582448/5634-15977-1-PB.gif 

--
View this message in context: http://r.789695.n4.nabble.com/Histogram-tp3582448p3582448.html
Sent from the R help mailing list archive at Nabble.com.
#
Have a look at:
http://addictedtor.free.fr/graphiques/thumbs.php

One of the graph examples they have is exactly what you are after.
On Wed, Jun 8, 2011 at 11:14 PM, nandini_bn <nandini_bn at hotmail.com> wrote:
#
I think the command you want is barplot

x  = rbinom(10,15,0.65)
y = rbinom(10,15,0.25)
barplot(rbind(x,y),beside=TRUE)


Sam
On Wed, Jun 8, 2011 at 10:14 AM, nandini_bn <nandini_bn at hotmail.com> wrote:
#
On 09/06/11 16:39, nandini_bn wrote:
RTFM.  I.e. execute

     ?rbinom

     cheers,

         Rolf Turner
#
Nice graphs there. Thanks. I too am looking to make a similar plot, with a
difference: I need only the top parts of the many 'histograms' (a
step-function like plot for histogram/bar-plots). I already have values for
"heights" of bars for x1-x2 intervals computed from a large survey data; I
want steps to be left-continuous; and step-functions to be plotted with
different lines and symbols for each of many groups.

I also want to make similar plots for cumulative 'histograms/bar-plots' to
compare groups. I have "cumulative heights" for x1-x2 intervals,
left-continuous. 

Any idea how to do this?

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Steven Kennedy
Sent: Thursday, June 09, 2011 3:28 AM
To: nandini_bn
Cc: r-help at r-project.org
Subject: Re: [R] Histogram

Have a look at:
http://addictedtor.free.fr/graphiques/thumbs.php

One of the graph examples they have is exactly what you are after.
On Wed, Jun 8, 2011 at 11:14 PM, nandini_bn <nandini_bn at hotmail.com> wrote:
______________________________________________
R-help at r-project.org mailing list
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.
#
It's difficult to understand what exactly you're looking for without
seeing an example, could you post a simple version?  imgur.com is a
website that lets you quickly upload pictures to share with others.

I think your problem can be solved with the type='s' option to the
general plot routine.  Consider the following three plots, I think the
third is the one you're looking for.

x = runif(10,0,1)
x2 = cumsum(x)

plot(x2)
plot(x2,type='l')
plot(x2,type='s')

Hope that helps,
Sam Stewart
On Thu, Jun 9, 2011 at 9:15 AM, Anupam <anupamtg at gmail.com> wrote:
#
Thanks. That is the type of graph I want, except with more options and
combinations. Here is an example with percent on Y-axis:
http://i.imgur.com/pr8M3.jpg This combines both 'histogram' and 'cumulative
histogram' type of data. In place of straight lines connecting the points I
want step-functions. I already have heights (y) and end points of x
intervals in a file (except for the last, x1-x2, where I only have x1). The
points are heights, left-continuous (they are at the end of the x1-x2
interval, and do not include x2).

-----Original Message-----
From: R Help [mailto:rhelp.stats at gmail.com] 
Sent: Thursday, June 09, 2011 5:58 PM
To: Anupam
Cc: Steven Kennedy; r-help at r-project.org
Subject: Re: [R] Histogram

It's difficult to understand what exactly you're looking for without seeing
an example, could you post a simple version?  imgur.com is a website that
lets you quickly upload pictures to share with others.

I think your problem can be solved with the type='s' option to the general
plot routine.  Consider the following three plots, I think the third is the
one you're looking for.

x = runif(10,0,1)
x2 = cumsum(x)

plot(x2)
plot(x2,type='l')
plot(x2,type='s')

Hope that helps,
Sam Stewart
On Thu, Jun 9, 2011 at 9:15 AM, Anupam <anupamtg at gmail.com> wrote:
wrote: