在Unix终端中,可以使用“less”或“more”命令逐页查看文本文件。我有一个300行的字符向量,我想逐页查看。你知道R中有类似的功能吗?
答案 0 :(得分:1)
如果您指的是R
环境中的对象(而不是驱动器上的文件),
你可能会喜欢我的小玩具:
short <- function(x=seq(1,20),numel=4,skipel=0,ynam=deparse(substitute(x))) {
ynam<-as.character(ynam)
#clean up spaces
ynam<-gsub(" ","",ynam)
#unlist goes by columns, so transpose to get what's expected
if(is.list(x)) x<-unlist(t(x))
if(2*numel >= length(x)) {
print(x)
}
else {
frist=1+skipel
last=numel+skipel
cat(paste(ynam,'[',frist,'] thru ',ynam,'[',last,']\n',sep=""))
print(x[frist:last])
cat(' ... \n')
cat(paste(ynam,'[',length(x)-numel-skipel+1,'] thru ', ynam, '[', length(x)-skipel,']\n',sep=""))
print(x[(length(x)-numel-skipel+1):(length(x)-skipel)])
}
}
blahblah版权归我所有,不是迪士尼blahblah免费使用,重复使用,编辑,洒在你的Wheaties等等。