d.scott at auckland.ac.nz
Thu Oct 8 22:55:41 CEST 2009
Henrique Dallazuanna wrote:
> Change the breaks argument:
> t1 <- hist(1:5, 0:5)
> On Thu, Oct 8, 2009 at 4:47 PM, Khanh Nguyen <knguyen at cs.umb.edu> wrote:
>> Hi all,
>> I have a question about hist()
>>> t1 <- hist(c(1,2,3,4,5))
>>  1 2 3 4 5
>>  2 1 1 1
>> why is there 2 counts for 1? And should the counts be '1 1 1 1 1' ?
>> Is there any other function to count frequency of discrete data?
Nobody has mentioned what I think is the important point here, that
histogram is not intended for the purpose of dealing with discrete data.
To expect that it will give you the counts you want is just wrong. As
others have pointed out if you make things more explicit and don't take
the defaults it will do so.
Using hist to obtain counts like this is like using a hammer to drive in
David Scott Department of Statistics
The University of Auckland, PB 92019
Auckland 1142, NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email: d.scott at auckland.ac.nz, Fax: +64 9 373 7018
Director of Consulting, Department of Statistics
More information about the R-help