[R] Histogram
R Help
rhelp.stats at gmail.com
Thu Jun 9 14:23:52 CEST 2011
I'm getting the impression that you're not overly familiar with R? If
so then you should really try and read some of the manuals from
r-project.org. R is a very complex language and has a steep learning
curve.
That being said, the command takes a 2xK array, where K is the number
of observations you have, and 2 is the number of categories (in your
case I picked two because your example has intervention and control).
The first two lines in my example were just to create some sample data
to work with.
For the graph example you provided, you would create a 2x13 matrix,
called dat, and then use the command
barplot(dat,beside=TRUE)
In terms of setting the x and y axis labels, and the tick-marks as
they are defined in the figure, see the options provided by ?barplot,
or type help.start() and search for barplot from there.
And to Rolf: I understand the frustration with posts that are simple
like this, but just because your type RTFM instead of the full
sentence doesn't mean you're not swearing at strangers on the
Internet. Try being a little more constrained in your responses.
Hope that helps,
Sam
On Thu, Jun 9, 2011 at 1:38 AM, Nandini B <nandini_bn at hotmail.com> wrote:
> Hi Sam,
> This is exactly what I wanted. Could you please explain the code ? what does
> 15, 0.65 and 0.25 stand for ?
>
>
> Nandini
>
>
>
>
>> Date: Wed, 8 Jun 2011 19:16:06 -0300
>> Subject: Re: [R] Histogram
>> From: rhelp.stats at gmail.com
>> To: nandini_bn at hotmail.com
>> CC: r-help at r-project.org
>>
>> 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:
>> >
>> > 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.
>> >
>> > ______________________________________________
>> > 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.
>> >
>
More information about the R-help
mailing list