Why not just define your own head
-type function. I use this one. It's been adjusted for a data.table
. This way, you can look at whatever you want. The first 3 rows are set as a default to save space.
peek <- function(d, x = ncol(d))
{
if (is.data.table(d)) d[1:3, 1:x, with = FALSE]
else if (is.data.frame(d) | is.matrix(d)) d[1:3, 1:x]
} ## note the 3 row default (to save space below)
On a data.table
:
> library(data.table)
> emteecars <- as.data.table(mtcars)
> peek(emteecars, 5)
# mpg cyl disp hp drat
# 1: 21.0 6 160 110 3.90
# 2: 21.0 6 160 110 3.90
# 3: 22.8 4 108 93 3.85
> peek(emteecars)
# mpg cyl disp hp drat wt qsec vs am gear carb
# 1: 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
# 2: 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
# 3: 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
Now on a data.frame
:
> peek(mtcars)
# mpg cyl disp hp drat wt qsec vs am gear carb
# Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
# Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
# Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
> peek(as.matrix(mtcars), 2)
# mpg cyl
# Mazda RX4 21.0 6
# Mazda RX4 Wag 21.0 6
# Datsun 710 22.8 4