问题标签 [ess]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1980 浏览

emacs - EMACS 折叠/展开 R 代码

是否有 Emacs 次要模式(或一段 elisp 代码)可让您在 Sweave(Sweave = R + LaTeX)中选择性地隐藏/显示环境?

例如,我想移动到代码块 (<<>>) 的开头,按一下键,然后将环境的内容隐藏起来。

这可能吗?我刚刚尝试了 hs-minor-mode、allout-mode 和 outline-minor-mode,但它们中的大多数都无法识别 R 环境。

我还尝试了非常适合折叠/展开的 org-mode,但不支持 LaTeX 突出显示代码,例如:\cite{}; \参考{}; \ce{} ...

最好的里卡多

- 编辑 -

我尝试了一天使用 emacs-folding-mode 但是,因为我处理的代码很长(超过 2000 行),折叠模式“发疯了”,例如误解了某些特殊字符(即 $)的挖掘,在 R 中的用途与在 LaTeX 中的用途非常不同。我认为这个问题是 Sweave 固有的,因为在同一个缓冲区中,我有 R 代码和 LaTeX 代码。

所以,现在我正在测试 emacs 大纲次要模式。但是,当我从 LaTeX(反之亦然)移动到 R 时,尽管我在 .emacs 中写道,但所有概述的部分都已展开:

你有什么建议吗??

问候

--编辑2--

它似乎工作:

我不知道是不是这样,当你离开大块时,它会自动展开。

0 投票
1 回答
270 浏览

r - Emacs + R: too long buffer name */usr/local/bin/R* for R buffers

I work with Emacs 24 (Emacs-pretest-24.0.91-universal-10.6.7 from http://emacsformacosx.com/builds) on Mac OS X 10.7.3 with R 2.15. When I open a new R buffer, the buffer name is */usr/local/bin/R*. For all other buffers I receive a reasonable file name, but for R buffers, the filename always contains this path. This is quite annoying if you have multiple R buffers open and you display a buffer menu (for example). Then you see a lot of buffers displayed as */usr/local/... and you can't see which of the buffers corresponds to which R process.

Is this a problem of the Mac or just my setup?

The only thing I can image as a reason for this is the following. To call R from the console (as from within Emacs), I defined a symbolic link in /usr/local/bin pointing to the correct path where R is installed. This link I called "R".

I could imagine that the emacs buffer name is determined from the link /usr/lcoal/bin/R but I don't know how to fix this since without the link I can't start R. On Ubuntu, I simply see the buffer name R (or R[2],... etc.), it would be great to have the same on Mac OS.

Update

0 投票
3 回答
1707 浏览

r - 在查找函数的帮助参考页面时如何指定包?

如何查找函数的帮助手册页并在 R 中指定包?例如,count 同时出现在 seqinr 和 plyr 中。如果我想在 plyr 中查找计数,命令是什么?我尝试了一些明显(但错误)的猜测,例如 "?plyr::count"

编辑: 当我做 ?count 时,我收到以下消息:

当我执行 ?plyr::count 时,我得到:

当我执行 ?plyr:::count 时,我得到:

添加两个问号也会给我一个没有找到文档的错误。查找非模棱两可功能的帮助工作正常(例如?情节)

这是在 emacs + ESS 中运行的 OSX 上的 R 2.15.0。

0 投票
1 回答
210 浏览

r - ESS 在指定包中找不到文档

我正在使用 ESS(12.04)、emacs(23.3.1) 和 R(2.14.1)。它工作得很好,只是如果函数在包内,我无法从 R 打开帮助。例如:

在 R(iESS 模式)

我会得到帮助文件,但如果我运行

我会得到“在指定的包和库中没有'caTools::runmean'的文档:你可以试试'??caTools::runmean'”。

我确信这是 ESS 的问题,因为如果我在 R 控制台中运行该命令,它工作得非常好。以下是我的 .emacs 文件中与 ESS 相关的部分:

我已经注释掉了我的大部分定制,试图在没有运气的情况下识别问题。如果有人有任何意见或怀疑,请指出给我。这一直困扰着我一段时间。非常感谢。

0 投票
1 回答
363 浏览

r - 在 Emacs 中更改低级 ess-mode 的背景颜色

由于我经常使用 Latex 和 Sweave/knitr,我想知道是否有可能在 Emacs 中更改不同模式的背景颜色,例如更改劣质-ess-mode (R) 或 ess-mode ( R-Scripts)变黑。起初,以下代码似乎有效。但是,一旦我从 ess-mode 更改为其他缓冲区/模式,就会应用颜色设置。

有没有办法只为 Emacs 中的 ess-mode/inferior-ess-mode 更改背景颜色?

0 投票
1 回答
620 浏览

r - Emacs 中的 r-autoyas

我正在尝试让 r-autoyas 在 Emacs 23.3.1 上工作

我已经安装了 yasnippet,它自己运行良好。例如:在 C++ 模式中,“for”之后的 TAB 会自动扩展。然后我继续让 r-autoyas 工作。我已按照 github 存储库中给出的说明进行操作,但无法让 TAB 扩展甚至是 R 缓冲区中的内置函数。

如果我输入 rnorm( 然后按 TAB 键,会打开一个小缓冲区,向我显示函数的各种参数。这是默认行为吗?还是应该将输入参数填充为默认值并让我一一更改?

我在网上搜索,看看有没有其他人遇到过这个问题。在一个论坛中,有人提到这可能是因为 Emacs 中的自动完成功能。

我的 init.el 文件中有以下几行,这些行在说明中给出:

(需要'r-autoyas)

(add-hook 'ess-mode-hook 'r-autoyas-ess-activate)

(add-hook 'ess-mode 'yas/minor-mode-on)

0 投票
1 回答
124 浏览

emacs - ESS 和 EC2 错误“R 进程已死亡”

我正在尝试将 ESS 与 EC2 一起使用。我在 EC2 控制台中启动一个实例,然后通过 ssh 进入该实例。

然后我开始 ESS

我选择的地方r。但是,当我尝试与进程交互时,我收到错误“R 进程已死亡”。但是,我可以通过将脚本中的命令粘贴到 shell 中来手动将命令输入到 shell 中。

0 投票
0 回答
187 浏览

r - R: ESS fails to deal with Thai script variable, but RGui is fine?

I have some code that scrapes some data from a website that happens to be in Thai script. As part of the project I need to replace some of the Thai text. A small example follows:

When I run this code from inside Emacs/ESS it does not work. Note how in the screenshot below the console cannot print the Thai characters to screen when the code is excecuted, nor can it apparently recognise the variables in thaidf$thdate, so the gsub() call does not succeed. Instead of producing '31 5 2555' where 31 is the day, 5 is the month and 2555 is the Buddhist year, it outputs '311 2555'

enter image description here

However, when I copy and paste this same code into the RGui front-end, it works fine. It both prints the characters, as shown below, and the gsub() correctly replaces the Thai script with Latin numbers, as one would expect. As you can see from the screengrab below, the Thai script for 'May' becomes '5' and the Thai script for 'April' becomes '4'.

enter image description here

My first thought was that it might be a font issue, but the Thai fonts do seem to be displayed in the Emacs buffer, they are just not recognised when the code is run with C-c M-b. Why does this happen? How can I prevent it?

sessionInfo() R version 2.15.0 Patched (2012-06-03 r59501) Platform: i386-pc-mingw32/i386 (32-bit)

locale: 1 LC_COLLATE=English_United Kingdom.1252 2 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 [4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252

attached base packages: 1 stats graphics grDevices utils datasets methods base

0 投票
4 回答
3037 浏览

r - 如何在 emacs-ess 中从 R 中访问 bash 环境变量

在我的 .bashrc 中,我有一行:

如果我在 bash 中加载 R,我可以使用以下Sys.getenv函数访问此变量:

如果我在 Emacs (Mx R) 中打开 R,则 SETTINGS 为空:

我试过的:

  1. 根据 如何使 Emacs 识别 bash 环境变量进行编译,将以下内容添加到 .emacs?

    /li>
  2. 使用在 emacs 中打开 bashM-x term

    /li>
  3. 如果我从终端打开 emacs,则 SETTINGS 变量可以按预期使用。从“应用程序”菜单(使用命令/usr/bin/emacs23 %Femacs)打开 emacs 不起作用。

  4. 比较session("env")在 bash 和 emacs 中加载 R 时的输出,但除了 (bash = <, emacs = >) 之外没有什么特别突出的:

    /li>

我也可以吗

  1. 在 emacs-ess 中从 R 中访问 SETTINGS
  2. 将设置导出到我可以访问的地方?
0 投票
1 回答
1816 浏览

emacs - ESS + AUCTeX + Sweave。来自 .Rnw <-> pdfviewer 的 SyncteX 集成?

我正在将我的工具链从 R + TeXShop 改造成我希望通过 emacs(Aquamacs,具体而言)更高效的 Sweave -> LaTeX -> SyncteX -> pdfview (skim) AUCTeX-mode (with emacs-speaks- statsitics 的 sweave 次要模式)。AUCTeX -> pdfview 链中的 SyncteX 一切正常,从 Sweave 编译为 .pdf 一切正常。

当我添加 Sweave 作为第一步时,麻烦就来了。.Rnw 文件现在成为主要的原始文档,它生成的 .tex 文件只是一个中间步骤。当然,SyncteX 锁定的是 .tex 文件。

我对 .emacs 文件所做的唯一更改是注册两个新命令以从 .Rnw 构建 .pdf。

谁能提供有关如何让 emacs 使用 SyncteX 将输出 .pdf 同步到 .Rnw 而不是 .tex 的建议?

谢谢!

编辑1: 警告:这最终成为我整个下午摸索的总结。我非常接近解决方案,但最后却被一个我找不到文档的错误所挫败。警告 2:今天是我第一次深入了解 emacs 的内部工作原理。肯定会出现错误或效率低下。

VitoshKa 的回答让我大部分时间都在那里。将他的建议添加到我的 .emacs(好吧,Preferences.el,但功能相同)文件中会导致Symbol’s value as variable is void: noweb-minor-mode-map启动时出错,因为 Aquamacs 似乎在其其余 init 文件之前加载 .emacs 文件。

我通过(require 'ess-site) (require 'ess-eldoc)在 VitoshKa 的(define-key noweb-minor-mode-map (kbd "\C-c \C-c") 'Rnw-command-master). 不幸的是,Aquamacs 附带的 ess-swv.elc 文件已经是二进制文件,并强制 Mn P 阅读器使用 acroread。因此,我将 ess-swv.el 文件的一部分的以下编辑添加到我自己的 .emacs 的底部:

现在 emacs 将使用Mn vCc Cc View RET从 emacs 以正确的 pdf 名称启动skim 。还有一个障碍要克服...

emacs 中的 Command-Shift-Click 尝试同步到 filename.Rnw.pdf(但丢弃错误消息至少仍会导致 pdfviewer 中的正确同步)。pdfviewer 中的 Command-Shift-Click 以搜索回源强制 emacs 打开 filename.tex 文件并同步到该文件。幸运的是,Cameron Bracken 对此进行了修复。他只是没有完全走上 emacs 集成的道路。

所以我在我的 .emacs 中添加了 ess-swv.el 的进一步破解:

认为这是缺少修补 DVI 并将其同步...但没有!Command-Shift-Click 上的行为与上面相同...回到破解 ess-swv。我删除了 ess-makePDFandView 函数,而是将以下内容添加到我的 .emacs 中:

越来越近了,但我们仍然需要告诉 auctex 要通过哪些文件名进行浏览。所以我硬着头皮编辑了 auctex-config.el。我注释掉了现有的 aquamacs-call-viewer 函数定义并将其替换为我自己的:

还有一个最终测试(请注意,我将工具链的键绑定更改为:Mn s -> Mn q -> Mn v 按 sweave -> latex -> view 的顺序[注意,对于最后一步,您必须使用 pdflatex 和不是texi2pdf]),一切都建立起来,没有错误,启动查看器......

现在我又完全迷路了。有人对Skim足够熟悉吗?

编辑 2:好吧,错误 127 只是在二进制文件中找不到文件。在那里的某个地方,我一定把路弄坏了。所以我(setenv "PATH" (concat (getenv "PATH") ":" "/Applications/Skim.app/Contents/MacOS"))在我的 auctex-config.el 顶部附近添加了。现在一切都编译并启动,没有错误......但是emacs上的Command-Shift-Click没有让Skim做出响应(至少它没有给出错误)。在 Skim 上的 Command-Shift-Click 仍然强制 emacs 打开 .tex 文件。

我想这现在已经成为一个非常 Aquamacs + Skim 的特定问题,因为其余的大部分交互都在 applescript 中,除非我在上面指出的 lisp 的关键行中遗漏了一些明显的东西。