deepayan.sarkar at gmail.com
2006-Nov-10 21:32 UTC
[Rd] unwarranted warning from hist.default (PR#9356)
> x = rnorm(100) > b = seq(min(x) - 1, max(x) + 1, length = 11) > b[1] -3.4038769 -2.7451072 -2.0863375 -1.4275678 -0.7687980 -0.1100283 [7] 0.5487414 1.2075111 1.8662808 2.5250506 3.1838203> > invisible(hist(x, breaks = b, include.lowest = TRUE, plot = FALSE))Warning message: argument 'include.lowest' is not made use of in: hist.default(x, breaks = b, include.lowest = TRUE, plot = FALSE) I don't think a warning is appropriate, since ?hist says: include.lowest: logical; if 'TRUE', an 'x[i]' equal to the 'breaks' value will be included in the first (or last, for 'right FALSE') bar. This will be ignored (with a warning) unless 'breaks' is a vector. and in this case 'breaks' does qualify as a "vector" by my understanding. Note that the warning goes away with 'plot=TRUE'. This suggests that this might have something to do with this vaguely worded entry in the NEWS for R 2.4.0: o hist(*, plot = FALSE) now warns about unused arguments. Neither the help page nor the NEWS file indicates what arguments are considered 'unused' when 'plot = FALSE', but either possibility --- (1) include.lowest is actually unused and (2) it is used and the warning is wrong --- is a bug.> sessionInfo()R version 2.4.0 Patched (2006-11-03 r39777) i486-pc-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] "methods" "stats" "graphics" "grDevices" "utils" "datasets" [7] "base" -Deepayan
deepayan.sarkar at gmail.com writes:> > x = rnorm(100) > > b = seq(min(x) - 1, max(x) + 1, length = 11) > > b > [1] -3.4038769 -2.7451072 -2.0863375 -1.4275678 -0.7687980 -0.1100283 > [7] 0.5487414 1.2075111 1.8662808 2.5250506 3.1838203 > > > > invisible(hist(x, breaks = b, include.lowest = TRUE, plot = FALSE)) > Warning message: > argument 'include.lowest' is not made use of in: hist.default(x, > breaks = b, include.lowest = TRUE, plot = FALSE) > > > I don't think a warning is appropriate, since ?hist says: > > include.lowest: logical; if 'TRUE', an 'x[i]' equal to the 'breaks' > value will be included in the first (or last, for 'right > FALSE') bar. This will be ignored (with a warning) unless > 'breaks' is a vector. > > and in this case 'breaks' does qualify as a "vector" by my understanding. > > Note that the warning goes away with 'plot=TRUE'. This suggests that > this might have something to do with this vaguely worded entry in the > NEWS for R 2.4.0: > > o hist(*, plot = FALSE) now warns about unused arguments. > > Neither the help page nor the NEWS file indicates what arguments are > considered 'unused' when 'plot = FALSE', but either possibility --- > (1) include.lowest is actually unused and (2) it is used and the > warning is wrong --- is a bug.As I read the code, the purpose is to warn people if they supply plot arguments (density, xlim, ylim,....) while plot=FALSE. There's a stop list coded by nf <- nf[is.na(match(nf, c("x", "breaks", "freq", "nclass", "plot", "probability")))] and I think the problem is just that "include.lowest" should have been on the list. -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
deepayan.sarkar at gmail.com
2006-Nov-10 23:29 UTC
[Rd] unwarranted warning from hist.default (PR#9356)
On 10 Nov 2006 23:39:14 +0100, Peter Dalgaard <p.dalgaard at biostat.ku.dk> wrote:> deepayan.sarkar at gmail.com writes: > > > > x = rnorm(100) > > > b = seq(min(x) - 1, max(x) + 1, length = 11) > > > b > > [1] -3.4038769 -2.7451072 -2.0863375 -1.4275678 -0.7687980 -0.1100283 > > [7] 0.5487414 1.2075111 1.8662808 2.5250506 3.1838203 > > > > > > invisible(hist(x, breaks = b, include.lowest = TRUE, plot = FALSE)) > > Warning message: > > argument 'include.lowest' is not made use of in: hist.default(x, > > breaks = b, include.lowest = TRUE, plot = FALSE) > > > > > > I don't think a warning is appropriate, since ?hist says: > > > > include.lowest: logical; if 'TRUE', an 'x[i]' equal to the 'breaks' > > value will be included in the first (or last, for 'right > > FALSE') bar. This will be ignored (with a warning) unless > > 'breaks' is a vector. > > > > and in this case 'breaks' does qualify as a "vector" by my understanding. > > > > Note that the warning goes away with 'plot=TRUE'. This suggests that > > this might have something to do with this vaguely worded entry in the > > NEWS for R 2.4.0: > > > > o hist(*, plot = FALSE) now warns about unused arguments. > > > > Neither the help page nor the NEWS file indicates what arguments are > > considered 'unused' when 'plot = FALSE', but either possibility --- > > (1) include.lowest is actually unused and (2) it is used and the > > warning is wrong --- is a bug. > > As I read the code, the purpose is to warn people if they supply plot > arguments (density, xlim, ylim,....) while plot=FALSE.That's not exactly what the NEWS entry says though.> There's a stop > list coded by > > nf <- nf[is.na(match(nf, c("x", "breaks", "freq", "nclass", > "plot", "probability")))] > > and I think the problem is just that "include.lowest" should have been > on the list.Yes. And while you are at it, my suggestion would be to either take 'probability' and 'freq' off that list (which would make the NEWS entry slightly more true) and/or clarify the intent of the warning. The current help page is silent about the warnings when 'plot FALSE', and I don't think that's a good thing. It's not exactly a bug, so I didn't file a bug report, but I did send a message to r-devel about it a while back. -Deepayan
cig32650 at syd.odn.ne.jp
2006-Nov-16 13:41 UTC
[Rd] unwarranted warning from hist.default (PR#9356)
> There's a stop> list coded by > > nf <- nf[is.na(match(nf, c("x", "breaks", "freq", "nclass", > "plot", "probability")))] > > and I think the problem is just that "include.lowest" should have been > on the list. I think that "right" should have been on the list, too. Refer to the following examples. The argument "right"fulfills the role. > set.seed(12345) > x <- rbinom(1000, 50, 0.3) > hist(x, right=FALSE, plot=FALSE)$counts [1] 5 36 81 182 238 234 140 63 21 Warning message: argument ?eright?f is not made use of in: hist.default(x, right = FALSE, plot = FALSE) > hist(x, right=TRUE, plot=FALSE)$counts [1] 22 51 131 218 243 197 94 35 9 Warning message: argument ?eright?f is not made use of in: hist.default(x, right = TRUE, plot = FALSE) > hist(x, plot=FALSE)$counts [1] 22 51 131 218 243 197 94 35 9