[R] Help with Hist

Steve Sidney sbsidney at mweb.co.za
Mon Nov 15 22:13:35 CET 2010


Hi Ivan / Dieter

Thanks for your assistance, I will try the suggestions.

The plotrix solution seems like the more elegant solution, except that 
unless I missing something I will land up with a value based graph 
rather than a density based one, which is what I really wanted.

It seems like the only solution will be to subset the data as has been 
suggested.

Regards
Steve

On 2010/11/15 06:45 PM, Ivan Calandra wrote:
> Well, another possibility would be to edit the plot so that you cut 
> the empty part (between 300 and 2000).
> There might be some function that can do it, maybe the 
> plotrix::gap.barplot() that Dieter already told you about.
>
> Le 11/15/2010 16:22, sbsidney at mweb.co.za a écrit :
>> Thanks
>>
>> What you have suggested of course works but I am trying to reduce the 
>> 'ugliness'.
>>
>> Anybody got any other ideas?
>>
>> Regards
>> Steve
>>
>> Sent from my BlackBerry® wireless device
>>
>> -----Original Message-----
>> From: Ivan Calandra<ivan.calandra at uni-hamburg.de>
>> Sender: r-help-bounces at r-project.org
>> Date: Mon, 15 Nov 2010 16:08:47
>> To:<r-help at r-project.org>
>> Reply-To: ivan.calandra at uni-hamburg.de
>> Subject: Re: [R] Help with Hist
>>
>> Hi,
>>
>> I think you should also give the upper extreme:
>>
>> x<- c(rnorm(80)+10, 101:110, 2001:2010)
>> hist(x, breaks=c(0, 20, 40, 60, 80, 100, 200, 500))
>> Error in hist.default(x, breaks = c(0, 20, 40, 60, 80, 100, 200, 500)) :
>>     some 'x' not counted; maybe 'breaks' do not span range of 'x'
>> hist(x, breaks=c(0, 20, 40, 60, 80, 100, 200, 500, 2100))  ## which
>> looks horrible, but works, up to you how to cut it
>>
>> HTH,
>> Ivan
>>
>> Le 11/15/2010 15:53, Steve Sidney a écrit :
>>> Dear list
>>>
>>> I am trying to re-scale a histogram and using hist() but can not seem
>>> to create a reduced scale where the upper values are not plotted.
>>>
>>> What I have is about 100 of which 80 or so are between a value of 0
>>> and 40 , one or two in the hundreds and an outlier around 2000.
>>>
>>> What I would like to do is create an x-scale that shows 5 bins between
>>> 0-100 and then 3/4 bins between 100 and 2000 but I don't need any
>>> resolution on the above 100 values.
>>>
>>> If I use breaks c(0, 20, 40, 60, 80, 100, 200, 500) R gives me an
>>> error saying that there are values not included, which of course I
>>> know but I wish to ignore them.
>>>
>>> It seems that I am missing something quite simple.
>>>
>>> Any help would be appreciated.
>>>
>>> Regards
>>> Steve
>>>
>>> ______________________________________________
>>> 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