Configure fix() and edit() to open in Notepad++ from R/RStudio
Asked Answered
O

2

6

When I do this in RStudio or RGUI:

fix(SomeFunction) 

(or using edit()) I can see the function's code in Notepad. Is there any way that I could change this so that the code preview opens in Notepad++ rather than plain old Notepad? And similarly, is there anyway that I could force View(SomeDataFrame) to open up in Excel?

Overexcite answered 21/12, 2012 at 12:55 Comment(0)
S
7

fix and edit functions invoke the editor defined in the "editor" argument.
By default, that argument is set to getOption('editor') as shown in the edit function documentation.

Therefore, you can either pass the notepad++ path as function argument, i.e. :

path <- "C:\\Program Files (x86)\\Notepad++\\Notepad++.exe"
fix(somefunction,editor=path)

or set notepad++ as default editor by changin R options for the current session i.e. :

path <- "C:\\Program Files (x86)\\Notepad++\\Notepad++.exe"

options(editor=path)

# from now on, all calls to fix and edit will open notepad++ as default editor...
fix(somefunction)

N.B.

If you want to set the new option as the default for all the next sessions, you should edit Rprofile.site script in RHome\etc path as explained here.

Shillelagh answered 21/12, 2012 at 13:16 Comment(1)
If you're on a computer with multiple R users it would be better to configure .Rprofile instead of .Rprofile.site.Participate
M
5

You could try something like this to create a temporary .csv and open in Excel.

Metamorphosis answered 21/12, 2012 at 13:50 Comment(2)
Thanks that's perfect. Unfortunately I can only mark one answer as accepted so I can only give you a measly +1.Galegalea
Obsolete now that RStudio views full datasetsHelpmeet

© 2022 - 2024 — McMap. All rights reserved.