函数类似于矩阵的 head()

function similar to head() for matrix

我正在寻找可以打印矩阵的任何包中的函数[1:5,1:5]。 head() 适用于列数较少但不适合大型矩阵的情况。我知道我可以为它创建自己的函数,但我想知道是否已经有一个函数。

在名为 futile.matrix 的包中有一个名为 peek 的函数。

library(futile.matrix)
m <- matrix(c(1,3,4,2, 5,10,11,2, 3,42,8,22, 23,15,3,8), ncol = 4)
peek(m, 4)

根据该函数的描述:

"Peek is a simple utility to conveniently look at a portion of a matrix. This is similar to head and tail but provides a 2-dimensional slice instead of a complete row."