1

I'm using R on OS X 10.6 and I prefer the unix console to the R.app for my work. If I issue a help command eg ?print the help content opens through a pager (i tried most and less), which however then hides out the content if I exit it bringing me back to the R input line.

What I really want is that the pager output stays on the screen even after I exit it back to R (hitting q).

I get this desired behaviour on other Readline-based Cli like psql for example, but not on R. Any hints on how this gets configured would be greatly appreciated.

xhienne
  • 5,738
  • 1
  • 15
  • 34
nikola
  • 5,286
  • 3
  • 22
  • 19

1 Answers1

6

The console pager that R uses can be set with the options function. With less, the -X option suppresses the terminal clearing at exit. So, if the less binary is located in "/bin" (not sure where it's located in OS X), this should work:

> options(pager="/bin/less -X")

If you want this to be the default behavior every time you start R, you can place the above command in your ~/.Rprofile file, which is run automatically at startup.

Alternatively, you can set a export LESS=-XF in ~/.bashrc and this will have an effect across all programs that use less as a pager. The F option would further exit straight away if the content is less than a page, which I find quite useful.

nikola
  • 5,286
  • 3
  • 22
  • 19
Jason Morgan
  • 2,260
  • 21
  • 24
  • For some reason, it works for help pages only. Can the same be applied to variables output? I remember Octave is used to redirect output to pager if it won't fit the screen. Is it possible in R? – baltazar Sep 09 '12 at 09:49
  • 1
    `df <- data.frame(matrix(rnorm(1000), ncol = 3))
    page(df, method = "print")`
    – Amos Folarin Oct 04 '13 at 13:18
  • Not working for me when adding an option to 'less' command. /bin/less -X: not found Warning message: error in running command – 3r1d May 05 '23 at 05:03