Skip to content

print only a few lines of an object

2 messages · John Fox, Naresh Gurbuxani

#
Dear Naresh,

You could try the brief() function in the car package, which has methods for matrices and data frames. For example:
Loading required package: carData
20000 x 200 matrix (19995 rows and 197 columns omitted)
                [,1] . . .     [,199]     [,200]
    [1,] -0.03153991       1.29516494 -2.6333638
    [2,]  0.21286783       0.01152682 -1.0662203
    [3,]  0.63017820       0.68932816  1.5035356
. . .                                                
[19999,]  2.68200662       0.24294658 -0.1350098
[20000,]  0.76880930       1.22899828 -1.3462279
20000 x 200 matrix (19990 rows and 190 columns omitted)
                [,1]        [,2]        [,3]       [,4]       [,5] . . .
    [1,] -0.03153991  1.51280101  0.56670537  1.3421424 -0.0901379      
    [2,]  0.21286783  0.01565378  0.36631559 -1.6334725 -0.4110920      
    [3,]  0.63017820  0.64677503  0.23708531 -1.0694868  0.6824060      
    [4,] -0.30640844 -0.50453994 -0.02955539 -0.3602093  0.9529470      
    [5,] -0.14800239 -0.36379589  0.26398965  0.7045783 -0.4371091      
             [,196]     [,197]      [,198]      [,199]     [,200]
    [1,]  2.4384271 -0.8562120  0.03272777  1.29516494 -2.6333638
    [2,]  2.3218889  0.9590918 -1.02492163  0.01152682 -1.0662203
    [3,]  0.5408822  1.1099126 -0.35874326  0.68932816  1.5035356
    [4,] -1.2347136  0.1547285 -0.94671222 -0.87190563 -0.8089031
    [5,]  0.1008432 -0.3179192  0.18579939 -0.31228407 -0.3491618
. . .                                                                        
[19996,]  0.77793106 -1.69263749 -0.11233025  0.1823454 -1.3472522      
[19997,]  0.50623281  1.63893912 -1.28729766  0.3620005  0.4693123      
[19998,] -1.25504937  0.34050657  0.48436453 -0.1727108  0.4209498      
[19999,]  2.68200662 -1.25888437  0.68085064 -0.3954497 -0.4057523      
[20000,]  0.76880930 -0.48637856  1.68292021  0.8830241  0.4467292      
                                                                 
[19996,]  1.1499971 -1.5115928 -0.97399354  1.21192716  0.4767529
[19997,]  0.5482631 -0.5797288 -0.13904089 -1.35133895  0.2814043
[19998,] -0.9352181 -1.1193794  0.37612204  1.09246093 -0.3628966
[19999,] -0.4141664 -0.5314562  0.60420993  0.24294658 -0.1350098
[20000,] -0.4208899 -1.4542644 -0.20223993  1.22899828 -1.3462279


I hope this helps,
 John

-----------------------------------------------------------------
John Fox
Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
Web: https://socialsciences.mcmaster.ca/jfox/
#
John,

This what I needed.  Thanks for your help,

Naresh