Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 15027 - max.print is ignored for matrix headers #14

Open
gmbecker opened this issue Jun 22, 2022 · 1 comment
Open

Bug 15027 - max.print is ignored for matrix headers #14

gmbecker opened this issue Jun 22, 2022 · 1 comment
Labels
discuss fix Add comment(s) on how to fix the bug I/O Issues related to the input/output system

Comments

@gmbecker
Copy link

https://bugs.r-project.org/show_bug.cgi?id=15027

Some analysis already done by @elinw.

@gmbecker gmbecker added discuss fix Add comment(s) on how to fix the bug I/O Issues related to the input/output system labels Jun 22, 2022
@huizezhang-sherry
Copy link

The bug is an observation that all the column names are printed out for a matrix. This is not a desirable behavior for printing large matrices, for example, in print(matrix(1:3000, nrow=2), all the 1500 columns names ([,1] [,2], ...[,1499] [,1500]) are printed.

This problem also happens in data frames where cbind(iris, iris, iris) will print out all the 15 columns, rather than doing some shrinkage.

Following the discussion in the link by @gmbecker, one thing to notice is that the discussion here is on the print of the columns name rather than the entry:

  • print(matrix(nrow = 100, ncol = 4), max = 5) will print 4 column names: [,1] [,2] [,3] [,4] and 4 entries of NA

  • print(matrix(nrow = 100, ncol = 20), max = 5) will print all the 20 column names and no entries

In the source code of print.data.frame(), the argument max gets the option max.print if it is NULL. It controls the number of entries get printed and has the behaviour that if the maximum number of entries allowed does not constitute a full row, no entry is printed (This explains why the first dot point prints out the NAs but the second one doesn't). @elinw has linked the source code for this.

The width argument in print() controls the width of the output, but still prints out all the column names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss fix Add comment(s) on how to fix the bug I/O Issues related to the input/output system
Projects
None yet
Development

No branches or pull requests

2 participants