[R] "Raw" histogram plots

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Feb 27 08:04:40 CET 2008


On Tue, 26 Feb 2008, Andre Nathan wrote:

> I know about stem, but the data set has 1 million points, so it's not
> very useful here. I want to avoid binning just to have an idea about the
> shape of the distribution, before deciding how I'll bin it.

Ideas:

1) use a much smaller sample of the data (1000 should suffice)
2) use a density plot (see ?density), perhaps on a sub-sample
(although as that will bin the data on a fine grid, this does not matter 
much).


>
> Andre
>
> On Tue, 2008-02-26 at 16:20 -0600, roger koenker wrote:
>> take a look at
>>
>> 	?stem
>>
>> There is still a place for handtools in the age of integrated
>> circuits.  Of course, avoiding binning isn't really desirable.
>>
>> url:    www.econ.uiuc.edu/~roger            Roger Koenker
>> email    rkoenker at uiuc.edu            Department of Economics
>> vox:     217-333-4558                University of Illinois
>> fax:       217-244-6678                Champaign, IL 61820
>>
>>
>> On Feb 26, 2008, at 4:10 PM, Andre Nathan wrote:
>>
>>> Hello
>>>
>>> I need to plot a histogram, but insted of using bars, I'd like to plot
>>> the data points. I've been doing it like this so far:
>>>
>>>  h <- hist(x, plot = F)
>>>  plot(y = x$counts / sum(x$counts),
>>>       x = x$breaks[2:length(x$breaks)],
>>>       type = "p", log = "xy")
>>>
>>> Sometimes I want to have a look at the "raw" data (avoiding any kind
>>> of
>>> binning). When x only contains integers, it's easy to just use bins of
>>> size 1 when generating h with "breaks = seq(0, max(x))".
>>>
>>> Is there any way to do something similar when x consists of fractional
>>> data? What I'm doing is setting a small bin length (for example,
>>> "breaks
>>> = seq(0, 1, by = 1e-6)", but there's still a chance that points will
>>> be
>>> grouped in a single bin.
>>>
>>> Is there a better way to do this kind of "raw histogram" plotting?
>>>
>>> Thanks,
>>> Andre
>>>
>>> ______________________________________________
>>> 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.
>>
>
> ______________________________________________
> 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.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list