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

From: David Whiting <david.whiting_at_ncl.ac.uk>
Date: Sat 09 Jul 2005 - 23:06:09 EST

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@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@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@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@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 Received on Sat Jul 09 23:13:02 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:27 EST