[R] Odd behavior in histogram breaks?

Rory.WINSTON at rbs.com Rory.WINSTON at rbs.com
Wed Aug 27 15:14:51 CEST 2008


I think the answer is in this line in hist.default():

  breaks <- pretty(range(x), n = breaks, min.n = 1)


> length(pretty(c(1:1000), 100))
[1] 101
> length(pretty(c(1:1000), 200))
[1] 201
> length(pretty(c(1:1000), 250))
[1] 201
> length(pretty(c(1:1000), 300))
[1] 201
> length(pretty(c(1:1000), 500))
[1] 501

Rory Winston
RBS Global Banking & Markets
Office: +44 20 7085 4476

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Glenn Lawyer
Sent: 27 August 2008 13:27
To: r-help at r-project.org
Subject: [R] Odd behavior in histogram breaks?

I am looking at histogram breaks, and notice something odd:
> foo <- hist(runif(10000),breaks=20)
> length(foo$breaks)
[1] 21
This makes sense to me.

> foo <- hist(runif(10000),breaks=200)
> length(foo$breaks)
[1] 201
This also makes sense.

BUT
> foo <- hist(runif(10000),breaks=250)
> length(foo$breaks)
[1] 201
> foo <- hist(runif(100000),breaks=250)
> length(foo$breaks)
[1] 201

Why only 201 breaks? Where did the other 50 go?

--
------------------------------------
Here miracles become marvels, and
marvels recurring wonders.
-- William Beebe

Dr. Glenn Lawyer
+352 661 967 244
Instituttgruppe for psykiatri
Seksjon Vinderen
PB 85 Vinderen
0319 Oslo
http://folk.uio.no/davidgl

        [[alternative HTML version deleted]]

______________________________________________
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.

***********************************************************************************
The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. 
Authorised and regulated by the Financial Services Authority 

This e-mail message is confidential and for use by the=2...{{dropped:22}}



More information about the R-help mailing list