5

Is there any way in a standard R environment how to show cursor position (at least line number) in script editor in R? I've tried to look at options but no success.

I am using R for Windows (XP, 7, ..).

Tomas
  • 57,621
  • 49
  • 238
  • 373
  • 2
    I doubt it ... it would help if you could say which OS you're using, because the answer may differ between Windows and MacOS. There has been relatively development of the GUI because there are so many alternatives for R development platforms (Eclipse, Emacs, RStudio, Tinn-R ...) – Ben Bolker Jan 02 '13 at 13:40
  • @BenBolker is correct that the script editor is platform dependent (i.e. it *does* differ between Windows and Mac). Which are you asking about? – Joshua Ulrich Jan 02 '13 at 13:52
  • @BenBolker and Joshua, thanks, I'm asking about Windows platform. – Tomas Jan 02 '13 at 14:00
  • another possibility suggested by http://www.sciviews.org/_rgui/projects/Editors.html is to use `options(editor=...)` ... although I don't know whether that actually replaces the script editor or just sets the editor used by `fix()`, `edit()` etc. I don't actually know where the Windows GUI code lives, otherwise I might go peek at it. – Ben Bolker Jan 02 '13 at 14:04
  • @BenBolker Windows, MacOS, and Linux :). And Vim is also an editor which supports R really well. However, for regular use, Rstudio is the best editor (or really IDE) for R. – Paul Hiemstra Jan 02 '13 at 14:05
  • 2
    It looks like the Windows GUI (graphapp) calls a "Rich edit" object within the windows system code. It is *possible* to get line numbers in such contexts: http://forums.codeguru.com/showthread.php?446242-rich-edit-control-line-numbering-number but it looks like a bit of a project (to be clear, I'm talking about hacking the source code for the Windows R GUI -- and presumably contributing the results back to the R project as a patch -- not an easy solution!) – Ben Bolker Jan 02 '13 at 14:12
  • Thanks @Ben, so this means that it is not possible with current builds, until someone hacks the code... Thank you for your effort! And if you happen to make the hack, I would be grateful! – Tomas Jan 02 '13 at 14:31

2 Answers2

6

According to Ben Bolkers' comments, it is not possible in current version of R (until someone hacks it).

Try R studio. It is perfect IDE for R development, I think that it has feature like this.

Tomas
  • 57,621
  • 49
  • 238
  • 373
Belphegor
  • 4,456
  • 11
  • 34
  • 59
  • 2
    well, I bet these GUI can do it, but I'm interested in solution for standard R environment. – Tomas Jan 02 '13 at 13:39
  • 3
    I would really recommend using Rstudio as a replacement for the standard R GUI. It comes with a ton of benefits (tab completion, object inspector, integrated graphics window, etc) that are really worthwhile. – Paul Hiemstra Jan 02 '13 at 14:03
  • @Paul, thanks, I always preferred the lightweight default over IDEs, but this sounds good - maybe I'll give it a chance... – Tomas Jan 02 '13 at 14:10
  • If you really want light-weight, but powerfull, do take a look at Vim. I agree that light-weight is good, but a lot of the stuff in Rstudio is just useful, making you more productive. – Paul Hiemstra Jan 02 '13 at 14:20
  • 1
    Rstudio isn't really much heavier than the Windows RGui in the first place, in my experience -- I think it dominates the Windows RGui (i.e., advantages but no disadvantages beyond the extra five minutes required to download it and set it up) – Ben Bolker Jan 02 '13 at 14:51
  • OK, I've added the @Ben Bolkers findings to the answer and accepted. – Tomas Jan 04 '13 at 16:53
  • IMHO. RStudio has serious problems working with network drives in windows. Also RSudio interface is not "mouse free". I preffere not to use mouse during working. – crow16384 Apr 10 '15 at 09:31
2

I think there comes a point where - if you're at all serious - you need to consider something more powerful than a text editor. Once you've come to that conclusion, the second thing you need to consider is whether you will be using the platform only for R or for other languages as well.

If you are coding only in R I think RStudio makes a lot of sense and you should certainly try it. For me it didn't quite 'fit' my way of working and in addition to R I use Perl and a bit of Python so I wanted something that could handle multiple languages. I eventually decided on and now use Emacs with ESS. This is not as obviously attractive and modern as RStudio but it is powerful, flexible and runs on just about any machine.

Vincent Goulet's package of Emacs and ESS for Windows is a good way to get started. Originally I liked KomodoIDE but R is not explicitly supported by ActiveState and I couldn't get it to work with R using third-party utilities so in the end I went with ESS. ESS has been a good choice for me.

SlowLearner
  • 7,907
  • 11
  • 49
  • 80