[R] truehist bug?

2007-03-19 Thread Gad Abraham
Hi,

Is this a bug in truehist()?

 > library(MASS)
 > x <- rep(1, 10)
 > truehist(x)
Error in pretty(data, nbins) : invalid 'n' value

Thanks,
Gad



 > R.version

platform   i486-pc-linux-gnu
arch   i486
os linux-gnu
system i486, linux-gnu
status
major  2
minor  4.1
year   2006
month  12
day18
svn rev40228
language   R
version.string R version 2.4.1 (2006-12-18)

 > sessionInfo()
R version 2.4.1 (2006-12-18)
i486-pc-linux-gnu

locale:
LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;
LC_COLLATE=en_AU.UTF-8;LC_MONETARY=en_AU.UTF-8;
LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;
LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;
LC_IDENTIFICATION=C

attached base packages:
[1] "stats" "graphics"  "grDevices" "utils" "datasets"  "methods"
[7] "base"

other attached packages:
 MASS
"7.2-32"


-- 
Gad Abraham
Department of Mathematics and Statistics
The University of Melbourne
Parkville 3010, Victoria, Australia
email: [EMAIL PROTECTED]
web: http://www.ms.unimelb.edu.au/~gabraham

__
R-help@stat.math.ethz.ch 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.


Re: [R] truehist bug?

2007-03-19 Thread Martin Maechler
> "Gad" == Gad Abraham <[EMAIL PROTECTED]>
> on Tue, 20 Mar 2007 17:02:18 +1100 writes:

Gad> Hi,
Gad> Is this a bug in truehist()?

>> library(MASS)
>> x <- rep(1, 10)
>> truehist(x)
Gad> Error in pretty(data, nbins) : invalid 'n' value

You get something similar though slightly more helpful
from
hist(x, "scott")

which then uses the same method for determining the number of bins /
classes for the histogram.

I'd say the main "bug" is in   
  nclass.scott()   [ and  also nclass.FD() ]

which do not work when  var(x) == 0  as in this case.
One could argue that  

1) truehist(x) should not use "scott" as
  default when var(x) == 0   {hence a buglet in truehist()}

and either

2) both hist() and truehist() should produce a better error
  message when "scott" (or "FD") is used explicitly and var(x) == 0

or, rather IMO,

3) nclass.scott(x) and nclass.FD(x) should be extended to return a 
  non-negative integer even when  var(x) == 0

Martin Maechler, ETH Zurich

__
R-help@stat.math.ethz.ch 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.