Bug 17312 - menu( > 10 items) repeats items when options("width") is big enough
Summary: menu( > 10 items) repeats items when options("width") is big enough
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Misc (show other bugs)
Version: 3.4.0
Hardware: Other Other
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2017-07-19 17:14 UTC by Bill Dunlap
Modified: 2017-07-20 15:22 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Dunlap 2017-07-19 17:14:56 UTC
When menu(graphics=FALSE) is given more than 10 choices it appears to lay them out in a row oriented format.  If options("width") is big enough that all entries can fit on one line with room to spare, the initial entries are repeated to fill the line.  E.g.,

checkMenu <- function (width, choices) 
{
    oldWidth <- options(width = width)
    on.exit(options(oldWidth))
    menu(choices)
}
> checkMenu(100, LETTERS[1:11])

 1: A   2: B   3: C   4: D   5: E   6: F   7: G   8: H   9: I  10: J  11: K   1: A   2: B   3: C


Selection: 0
[1] 0
> cat(strrep(".",100), "\n")
.................................................................................................... 

> checkMenu(150, LETTERS[1:11])

 1: A   2: B   3: C   4: D   5: E   6: F   7: G   8: H   9: I  10: J  11: K   1: A   2: B   3: C   4: D   5: E   6: F   7: G   8: H   9: I  10: J


Selection: 0
[1] 0
> cat(strrep(".",150),"\n")
......................................................................................................................................................


> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS: /usr/lib64/libblas.so.3.4.2
LAPACK: /home/R/R-3.4.0/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

loaded via a namespace (and not attached):
[1] compiler_3.4.0
Comment 1 Martin Maechler 2017-07-20 15:22:06 UTC
Thank you, Bill!

The code wrongly assumed  length(choices) >= #{elements fitting in one row}.

One could say this bug was harder to detect than to fix ;-)

Fixed for R-devel and R-patched.