Adrián Cortés
2009-May-15 15:58 UTC
[R] Printing to screen a matrix or data.frame in one chunk (not splitting columns)
Hello, I saw this nice trick I want to replicate but I lost the source and I hope one of you can point me to the solution. My problem is that I don't know the correct words to query this. When I print to screen a matrix or data.frame the columns are split and printed below the previous ones; even though I have plenty of screen left. E.g.,> my_matrix = matrix(runif(30),nrow=3,ncol=10) > my_matrix[,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,] 0.4979305 0.1155717 0.4484069 0.29986049 0.5427566 0.4324351 0.269171456 [2,] 0.8405987 0.3605237 0.6615507 0.75305248 0.8569482 0.3401004 0.192526423 [3,] 0.5608779 0.3953941 0.9995035 0.03141064 0.7985053 0.4903582 0.000490054 [,8] [,9] [,10] [1,] 0.1402751 0.2852381 0.98816751 [2,] 0.8337806 0.7322920 0.17505541 [3,] 0.5414113 0.4668012 0.04420137 So there is a way to resize the space for printing so that everything in printed in one chunk. Thanks in advance, Adrian [[alternative HTML version deleted]]
Marc Schwartz
2009-May-15 16:39 UTC
[R] Printing to screen a matrix or data.frame in one chunk (not splitting columns)
On May 15, 2009, at 10:58 AM, Adri?n Cort?s wrote:> Hello, > > I saw this nice trick I want to replicate but I lost the source and > I hope > one of you can point me to the solution. My problem is that I don't > know > the correct words to query this. > > When I print to screen a matrix or data.frame the columns are split > and > printed below the previous ones; even though I have plenty of screen > left. > > E.g., > >> my_matrix = matrix(runif(30),nrow=3,ncol=10) >> my_matrix > [,1] [,2] [,3] [,4] [,5] [,6] > [,7] > [1,] 0.4979305 0.1155717 0.4484069 0.29986049 0.5427566 0.4324351 > 0.269171456 > [2,] 0.8405987 0.3605237 0.6615507 0.75305248 0.8569482 0.3401004 > 0.192526423 > [3,] 0.5608779 0.3953941 0.9995035 0.03141064 0.7985053 0.4903582 > 0.000490054 > [,8] [,9] [,10] > [1,] 0.1402751 0.2852381 0.98816751 > [2,] 0.8337806 0.7322920 0.17505541 > [3,] 0.5414113 0.4668012 0.04420137 > > So there is a way to resize the space for printing so that > everything in > printed in one chunk. > > Thanks in advance, > AdrianSee ?options and take note of 'width' which defaults to 80. Increase that value to a number that suits your requirements. HTH, Marc Schwartz
Martin Maechler
2009-May-15 16:42 UTC
[R] Printing to screen a matrix or data.frame in one chunk (not splitting columns)
>>>>> "AC" == Adri?n Cort?s <adrcort at gmail.com> >>>>> on Fri, 15 May 2009 08:58:04 -0700 writes:AC> Hello, AC> I saw this nice trick I want to replicate but I lost the source and I hope AC> one of you can point me to the solution. My problem is that I don't know AC> the correct words to query this. AC> When I print to screen a matrix or data.frame the columns are split and AC> printed below the previous ones; even though I have plenty of screen left. AC> E.g., >> my_matrix = matrix(runif(30),nrow=3,ncol=10) >> my_matrix AC> [,1] [,2] [,3] [,4] [,5] [,6] AC> [,7] AC> [1,] 0.4979305 0.1155717 0.4484069 0.29986049 0.5427566 0.4324351 AC> 0.269171456 AC> [2,] 0.8405987 0.3605237 0.6615507 0.75305248 0.8569482 0.3401004 AC> 0.192526423 AC> [3,] 0.5608779 0.3953941 0.9995035 0.03141064 0.7985053 0.4903582 AC> 0.000490054 AC> [,8] [,9] [,10] AC> [1,] 0.1402751 0.2852381 0.98816751 AC> [2,] 0.8337806 0.7322920 0.17505541 AC> [3,] 0.5414113 0.4668012 0.04420137 AC> So there is a way to resize the space for printing so that everything in AC> printed in one chunk. options(width = 100) # or whatever. --- For ESS users, this option is set to the "correct" value, when R is started. If later, the emacs window is resized, you can automatically set the width to the current buffer ("window") size, by M-x ess-execute-screen-options or, for everyone here who has (add-hook 'ess-mode-hook 'ess-add-MM-keys) (add-hook 'inferior-ess-mode-hook 'ess-add-MM-keys) in their ~/.emacs equivalent, it's a simple "C-c w" ('w' for 'width') to adapt the R option to the emacs window size. Martin Maechler, ETH Zurich