[R] Printing to screen a matrix or data.frame in one chunk (not splitting columns)

Marc Schwartz marc_schwartz at me.com
Fri May 15 18:39:25 CEST 2009


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,
> Adrian



See ?options and take note of 'width' which defaults to 80. Increase  
that value to a number that suits your requirements.

HTH,

Marc Schwartz




More information about the R-help mailing list