配置 fix() 和 edit() 从 R/RStudio 在 Notepad++ 中打开 [英] Configure fix() and edit() to open in Notepad++ from R/RStudio

查看:42
本文介绍了配置 fix() 和 edit() 从 R/RStudio 在 Notepad++ 中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 RStudio 或 RGUI 中执行此操作时:

When I do this in RStudio or RGUI:

fix(SomeFunction) 

(或使用 edit())我可以在记事本中看到函数的代码.有什么办法可以改变这一点,以便代码预览在 Notepad++ 而不是普通的旧记事本中打开?同样,无论如何我可以强制 View(SomeDataFrame) 在 Excel 中打开?

(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?

推荐答案

fixedit 函数调用在 "editor" 争论.
默认情况下,该参数设置为 getOption('editor'),如 编辑函数文档.

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.

因此,您可以将 notepad++ 路径作为函数参数传递,即:

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)

或通过更改当前会话的 R 选项将 notepad++ 设置为默认编辑器,即:

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)

注意

如果您想将新选项设置为所有下一个会话的默认选项,您应该按照说明在 RHome\etc 路径中编辑 Rprofile.site 脚本此处.

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.

这篇关于配置 fix() 和 edit() 从 R/RStudio 在 Notepad++ 中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆