[R] "more" and "tab" functionalities in R under linux

David Whiting david.whiting at ncl.ac.uk
Sat Jul 9 15:06:09 CEST 2005


Here's a very simple function that more literally emulates 'more'. It
would probably become irritating on dataframes with many columns or
rows. (Note that this is quick code thrown together and could probably
be simplified and/or improved.)

more <- function(x, num.rows=20)
{
  ## Purpose:display a dataframe in a 'more'-like manner
  ## -------------------------------------------------------------------
  ## Arguments:
  ## x: a data frame
  ## num.rows: number of rows to show at a time.
  ## -------------------------------------------------------------------
  show.more <- TRUE
  start.row <- 1
  while (show.more) {
    print(x[start.row:(start.row + num.rows), ])
    pc.shown <- round(((start.row + num.rows) / nrow(x)) * 100, 1)
    ans <- readline(paste("--More--(", pc.shown, "%)\n", sep=""))
    if (ans == "q") {
      show.more <- FALSE
    } else {
      start.row <- start.row + num.rows + 1
    }
  }
}

David

Gabor Grothendieck wrote:
> Here are some possibilities:
> - head(iris) will show the first few rows of the data frame
> - edit(iris) will put up a spreadsheet with the data frame in it that
> you can scroll
> - In JGR (a GUI front end for R) you can use the object browser (ctrl-B)
> - If the object is a file rather than a data frame use file.show
> 
> On 7/8/05, Weiwei Shi <helprhelp at gmail.com> wrote:
> 
>>Hi,
>>forgive me if it is due to my "laziness" :)
>>I am wondering if there are functionalities in R, which can do like
>>"more" and "tab" in linux:
>>more(one.data.frame) so I can browse through it. Sometimes I can use
>>one.data.frame[1:100,], but still not as good as "more" in linux.
>>
>>tab:
>>can I use tab to auto complete an defined object name in R so I don't
>>have to type the full name? I knew ESS can do it but it is a little
>>bit funny when I use ESS and it can delete something that you cannot
>>delete from R, like pressing del key all the time and you see what i
>>mean.
>>
>>thanks,
>>
>>weiwei
>>--
>>Weiwei Shi, Ph.D
>>
>>"Did you always know?"
>>"No, I did not. But I believed..."
>>---Matrix III
>>
>>______________________________________________
>>R-help at stat.math.ethz.ch mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
> 
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list