当我在RStudio或RGUI中执行此操作时:
fix(SomeFunction)
(或使用edit()
)我可以在记事本中看到函数的代码。有没有什么办法可以改变这个,以便代码预览在Notepad ++而不是普通的旧记事本中打开?同样,无论如何,我可以强制View(SomeDataFrame)
在Excel中打开吗?
答案 0 :(得分:7)
fix
和edit
函数调用"editor"
参数中定义的编辑器。
默认情况下,该参数设置为getOption('editor')
,如edit function documentation。
因此,您可以将notepad ++路径作为函数参数传递,即:
path <- "C:\\Program Files (x86)\\Notepad++\\Notepad++.exe"
fix(somefunction,editor=path)
或将notepad ++设置为当前会话的changin R选项的默认编辑器,即:
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。强>
如果您要将新选项设置为所有下一个会话的默认选项,则应按照here中的说明在Rprofile.site
路径中修改RHome\etc
脚本。
答案 1 :(得分:5)
您可以尝试this之类的内容来创建临时.csv并在Excel中打开。