4

Is there any way to display the code syntax colored in R? I don't wish to use RStudio, TinnR etc. to accomplish the same. Please specify.

I have connected it to sublime and used it editor which is pretty good, but I am looking for some simplistic approach.

This question somewhat comes close what I am asking. But I guess mine pretty simple.

It seems weird it wouldn't be possible to accomplish something already which should implicit.

Right now(No syntax color):

 write.csv2(dfwith, file = "writecsv2.csv")

Required(With Syntax Color):

<div style="overflow:auto;"><div class="geshifilter"><pre class="r geshifilter-R" style="font-family:monospace;"> <a href="http://inside-r.org/r-doc/utils/write.csv2"><span style="color: #003399; font-weight: bold;">write.csv2</span></a><span style="color: #009900;">&#40;</span>dfwith<span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/file"><span style="color: #003399; font-weight: bold;">file</span></a> = <span style="color: #0000ff;">&quot;writecsv2.csv&quot;</span><span style="color: #009900;">&#41;</span></pre></div></div><p><a href="http://www.inside-r.org/pretty-r" title="Created by Pretty R at inside-R.org">Created by Pretty R at inside-R.org</a></p>
Community
  • 1
  • 1
Abhishek Bhatia
  • 9,404
  • 26
  • 87
  • 142

1 Answers1

2

I'm not entirely certain what you're trying to accomplish, as your question is pretty ambiguous, but hopefully this could be of some help.

As an alternative to Sublime, you can use Notepad++ as R's "built-in" editor. By this I mean that you would create/edit functions and scripts in Notepad++:

The result of fixing a function

(This screenshot is how it looks on my dual monitors)

Typing fix(some_func) or some_func <- edit(some_func) would both open in Notepad++.

If this seems like something you're looking for, it can be done by going to ‘R_HOME/etc/Rprofile.site’, where R_HOME is the directory it's installed. After locating the Rprofile.site file, open it in Notepad++ and change the following:

# options(papersize="a4")
options(editor="notepad")
# options(pager="internal")

to:

# options(papersize="a4")
options(editor="C://Program Files (x86)//Notepad++//notepad++.exe")
# options(pager="internal")

Save the file and you're done.

js10022
  • 66
  • 3