Skip to content

Syntax coloring in R console

11 messages · Steve_Friedman at nps.gov, Liviu Andronic, January Weiner +4 more

#
Dear all,

I am a happy user of R console, but I would like to see syntax
coloring. I use R 2.12 in Ubuntu Linux.

I have found the packages "xterm256" and "highlight", but I was not
able to figure out how to use it to highlight the syntax in console
output.

Also, I tried several GUI interfaces, but I was not able to find
something that suits me better than the default R console. R cmdr is
definitely not for me, as I don't want to fundamentally change the way
I am managing my data in R. Rkwrd seems to be nice (from screenshots),
but its installation requires all the base KDE libraries, which I
don't want to install.

I tried JGR, the GUI for R, but I have found the following problems
with this package:

- I was not able to change the background color from a repulsive grey,
- apparently, GNU readline is not implemented in that package, that
is, there is no functionality similar to ctrl-r (which searches
through the history for matching commands), something I use
frequently, and
- tab expansion is of limited use (e.g. doesn't browse files in the
current directory when expanding quoted arguments e.g. in
"read.table").

All in all, I'd be happy to continue using the plain R console, but
syntax highlighting would be nice. Any advice would be extremely
welcome.

Kind regards,

January
R version 2.12.2 (2011-02-25)
Platform: i486-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8     LC_MONETARY=C
 [6] LC_MESSAGES=en_US.utf8    LC_PAPER=en_US.utf8       LC_NAME=C
            LC_ADDRESS=C              LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


--
#
RStudio is a new interface. I just started using it and find it very good.
You might want to check it out.  It does have Ubuntu capabilities, but you
have be sure that your graphic drivers are the same as is specified in the
RStudio system.

Hope this helps

Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

Steve_Friedman at nps.gov
Office (305) 224 - 4282
Fax     (305) 224 - 4147


                                                                           
             January Weiner                                                
             <january.weiner at m                                             
             piib-berlin.mpg.d                                          To 
             e>                        <r-help at stat.math.ethz.ch>          
             Sent by:                                                   cc 
             r-help-bounces at r-                                             
             project.org                                           Subject 
                                       [R] Syntax coloring in R console    
                                                                           
             04/01/2011 06:32                                              
             AM                                                            
                                                                           
                                                                           
                                                                           




Dear all,

I am a happy user of R console, but I would like to see syntax
coloring. I use R 2.12 in Ubuntu Linux.

I have found the packages "xterm256" and "highlight", but I was not
able to figure out how to use it to highlight the syntax in console
output.

Also, I tried several GUI interfaces, but I was not able to find
something that suits me better than the default R console. R cmdr is
definitely not for me, as I don't want to fundamentally change the way
I am managing my data in R. Rkwrd seems to be nice (from screenshots),
but its installation requires all the base KDE libraries, which I
don't want to install.

I tried JGR, the GUI for R, but I have found the following problems
with this package:

- I was not able to change the background color from a repulsive grey,
- apparently, GNU readline is not implemented in that package, that
is, there is no functionality similar to ctrl-r (which searches
through the history for matching commands), something I use
frequently, and
- tab expansion is of limited use (e.g. doesn't browse files in the
current directory when expanding quoted arguments e.g. in
"read.table").

All in all, I'd be happy to continue using the plain R console, but
syntax highlighting would be nice. Any advice would be extremely
welcome.

Kind regards,

January
R version 2.12.2 (2011-02-25)
Platform: i486-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C
LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8     LC_MONETARY=C
 [6] LC_MESSAGES=en_US.utf8    LC_PAPER=en_US.utf8       LC_NAME=C
            LC_ADDRESS=C              LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


--

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
#
Hello


On Fri, Apr 1, 2011 at 12:32 PM, January Weiner
<january.weiner at mpiib-berlin.mpg.de> wrote:
I've been in this position before, without finding a solution for
syntax highlighting in the default R console.
Recently RStudio was introduced [1] and, although beta, it received
quasi-unanimous acclaim from the community, so you risk finding it
useful too.
[1] http://alternativeto.net/software/rstudio/about

Regards
Liviu

  
    
  
#
Dear Liviu,

RStudio might be a fine program, but it does not feature syntax
highlighting, which is the only thing I am missing from R Console (it
only colors the commands typed). Moreover, the very idea of squeezing
all R windows into one "window-desktop" would be counterproductive in
my particular case.

Thank you anyways!

j.

  
    
#
Dear January,

Have a look at Eclipse with the STAT-ET plugin http://www.walware.de/goto/statet

Best regards,

Thierry

----------------------------------------------------------------------------
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
#
On Fri, Apr 1, 2011 at 3:48 PM, January Weiner
<january.weiner at mpiib-berlin.mpg.de> wrote:
The idea is that you shouldn't use the R console for you main
programming needs, but only for quick and dirty checks. For the bulk
of programming tasks you are invited to use the integrated editor
(File > New > Script). The editor window does feature syntax
highlighting, and a very helpful completion mechanism (via <tab>).
Sending lines for execution to the terminal is as easy as clicking
'run lines' or ctrl+enter. If you're not a fan of keeping scripts for
your projects you can easily use temporary files that you don't save.
Notice that all panes are freely resizable and can be resized to the
point of becoming hidden. Future releases will give more control over
the panes layout (I think).

Regards
Liviu

  
    
  
#
Dear January,

Have you looked at Emacs + ESS?  http://ess.r-project.org/

It highlights in the text editor and the actual R process besides
coming with a rich set of features and a mailing list filled with
helpful Emacs & R users.  I've tried several different interfaces and
ended up being happiest by far with Emacs + ESS.  I also seem to
recall Kate or Kedit at least highlighted .R files, but I am not in a
position to check right now.

Happy hunting,

Josh

On Fri, Apr 1, 2011 at 3:32 AM, January Weiner
<january.weiner at mpiib-berlin.mpg.de> wrote:

  
    
#
Dear Liviu,

thanks for the programming tip! However, I do all my editing in vim,
which has had syntax highlighting for quite a while, as well as
auto-completion and a number of other goodies. But while I do most of
my programing in vim, I do most of my scientific studies simply using
the R interface and keeping a manually edited "lab book" apart from
the scripts. Clearly, one can do as much with Rstudio -- I just don't
see any advantages, but I do see a disadvantage in my specific case:
all sub-windows are confined to the "desktop". In other words, having
multiple plots on one monitor and a terminal with R command line is
not possible.

A question, though. Given that I have projects assorted in various
directories, how can I start RStudio opening a project stored in
.RData and .Rhistory of a given directory? I.e., how can I make
RStudio open the current directory (like R does), and not $HOME?

Thanks nonetheless,

j.
On Fri, Apr 1, 2011 at 4:20 PM, Liviu Andronic <landronimirc at gmail.com> wrote:

  
    
#
Am 01.04.2011 17:02, schrieb Joshua Wiley:
Another vote for Emacs + ESS here.
I think sooner or later you'll need some kind of editor (with built-in 
syntax highlighing) to save your code. The "naked" R console won't do it 
forever :)

Although I didn't like Emacs at first because of its steep learning 
curve, after a while you'll love the keyboard shortcuts for everything.

Also, this add-on is very useful. It makes Shift-Enter send your lines 
to R (and a bit more):
http://www.kieranhealy.org/blog/archives/2009/10/12/make-shift-enter-do-a-lot-in-ess/
#
Please move this thread off r-help. It's about Rstudio, not R.

-- Bert

On Fri, Apr 1, 2011 at 8:05 AM, January Weiner
<january.weiner at mpiib-berlin.mpg.de> wrote:

  
    
#
On Fri, Apr 1, 2011 at 5:05 PM, January Weiner
<january.weiner at mpiib-berlin.mpg.de> wrote:
For info, vim has plug-in for R.
I see. This would be more of a hack, but you could use playwith as an
external graphics device. Otherwise, there seems to be an easy hack:
This is a known issue and the RStudio devels plan to address this.
Currently I simply open RStudio in $HOME (and make sure that there is
no existent .RData there), then open the .RData from my project's
directory (by clicking on it in the right-hand Files pane) and then in
the same pane I hit More > Set as working dir. A bit cumbersome, but
seems to work, and a small price to pay for all the available
functionality.

Regards
Liviu