function similar to head() for matrix

一个人想着一个人 提交于 2019-12-02 04:01:58

问题


I am looking for a function in any package that can print matrix[1:5, 1:5]. head() is good for those that have few columns but not for a large matrix. I know I can create my own function for it but I am wondering if there is a function for it already.


回答1:


There is a function called peek in a package called futile.matrix.

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)

From the description of that function:

"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."



来源:https://stackoverflow.com/questions/30905852/function-similar-to-head-for-matrix

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!