I have always found startup profile files of other people both useful and instructive about the language. Moreover, while I have some customization for Bash and Vim, I have nothing for R.
For example, one thing I always wanted is different colors for input and output text in a window terminal, and maybe even syntax highlighting.
I've got this, more dynamic trick to use full terminal width, which tries to read from the COLUMNS environment variable (on Linux):
This way R will use the full width even as you resize your terminal window.
I found two functions really necessary: First when I have set
debug()
on several functions and I have resolved the bug, so I want toundebug()
all functions - not one by one. Theundebug_all()
function added as the accepted answer here is the best.Second, when I have defined many functions and I am looking for a specific variable name, it's hard to find it within all results of the the
ls()
, including the function names. Thelsnofun()
function posted here is really good.Here's from my ~/.Rprofile, designed for Mac and Linux.
These make errors easier to see.
I hate the CRAN menu choice, so set to a good one.
More history!
The following is for running on Mac OSX from the terminal (which I greatly prefer to R.app because it's more stable, and you can organize your work by directory; also make sure to get a good ~/.inputrc). By default, you get an X11 display, which doesn't look as nice; this instead gives a quartz display same as the GUI. The
if
statement is supposed to catch the case when you're running R from the terminal on Mac.And preload a few libraries,
where util.r is a random bag of stuff I use, under flux.
Also, since other people were mentioning console width, here's how I do it.
This actually isn't in
.Rprofile
because you have to re-run it every time you resize the terminal window. I have it inutil.r
then I just source it as necessary.Mine includes
options(menu.graphics=FALSE)
because I like to Disable/suppress tcltk popup for CRAN mirror selection in R.Here's mine. I always use the main cran repository, and have code to make it easy to source in-development package code.
Stephen Turner's post on .Rprofiles has several useful aliases and starter functions.
I find myself using his ht and hh often.