WinXP emacs 上远程 R 的双重提示和乱码 R 帮助

发布于 2024-09-11 02:48:07 字数 4592 浏览 6 评论 0原文

我已经从 Vincent Goulet 安装了一个修改版 Emacs 版本(来自 Vincent Goulet),并且我想使用 ess-remote 运行和编辑远程 Unix 服务器上包含的 R 脚本。经过大量搜索后,我能够通过以下方式连接到远程 R 会话:

  1. 使用 Mx shell 打开 shell 提示符,
  2. 输入以下命令:plink -X -C username@server
  3. ,我使用一个简单的命令在 shell 中启动 R R
  4. 使用命令 Mx ess-remote 将其指定为远程进程

输入密码后 为了成功地与 R 交互,我总是得到双重提示,更糟糕的是,如果打开函数的帮助文件,我会在同一个 R 进程缓冲区中得到乱码文本,而不是打开带有清晰 R 帮助文本的新缓冲区。如何获得帮助缓冲区以在单独的窗口中打开,就像通常的 emacs 和 R 交互一样,以及如何在执行 shell 时摆脱双提示?

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

c:\Documents and Settings\username>plink -X -C username@remoteserver
plink -X -C username@remoteserver
username@remoteserver's password: 

[username@remoteserver ~]$ R
R

R version 2.11.0 (2010-04-22)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.


Welcome at Sat Jul 24 11:50:45 2010 
> 
> options(STERM='iESS')
options(STERM='iESS')
> 
> x <- c(1,2,3)
> 
> x
[1] 1 2 3
> 
> ?mean(x)
  [?1049h[?1h=[24;1H[Kmean                   package:base                    R        Documentation

Arithmetic Mean

Description:

 Generic function for the (trimmed) arithmetic mean.

Usage:

 mean(x, ...)

 ## Default S3 method:
 mean(x, trim = 0, na.rm = FALSE, ...)

Arguments:

   x: An R object.  Currently there are methods for numeric/logical
      vectors and date, date-time and time interval objects, and
      for data frames all of whose columns have a method.  Complex
      vectors are allowed for 'trim = 0', only.

trim: the fraction (0 to 0.5) of observations to be trimmed from

[24;1H[K:[24;1H[24;1H[K] 计算平均值之前“x”的每一端。修剪值 [24;1H[K: [24;1H[24;1H[K 超出该范围被视为最近的端点。

na.rm: a logical value indicating whether 'NA' values should be
      stripped before the computation proceeds.

 ...: further arguments passed to or from other methods.

Value:

 For a data frame, a named vector with the appropriate method being
 applied column by column.

 If 'trim' is zero (the default), the arithmetic mean of the values
 in 'x' is computed, as a numeric or complex vector of length one.
 If 'x' is not logical (coerced to numeric), numeric (including
 integer) or complex, 'NA_real_' is returned, with a warning.

 If 'trim' is non-zero, a symmetrically trimmed mean is computed
 with a fraction of 'trim' observations deleted from each end
 before the mean is computed.

References:

[24;1H[K:[24;1H[24;1H[K     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
[24;1H[K:[24;1H[24;1H[K     Language_.  Wadsworth & Brooks/Cole.
[24;1H[K:
[24;1H[24;1H[K
[24;1H[K:[24;1H[24;1H[KSee Also:
[24;1H[K:
[24;1H[24;1H[K
[24;1H[K:[24;1H[24;1H[K     'weighted.mean', 'mean.POSIXct', 'colMeans' for row and     column
[24;1H[K:
[24;1H[24;1H[K     means.
[24;1H[K:[24;1H[24;1H[K
[24;1H[K:
[24;1H[24;1H[KExamples:
[24;1H[K:[24;1H[24;1H[K
[24;1H[K:
[24;1H[24;1H[K     x <- c(0:10, 50)
[24;1H[K:[24;1H[24;1H[K     xm <- mean(x)
[24;1H[K:
[24;1H[24;1H[K     c(xm, mean(x, trim = 0.10))
[24;1H[K:[24;1H[24;1H[K     
[24;1H[K:
[24;1H[24;1H[K     mean(USArrests, trim = 0.2)
[24;1H[K:[24;1H[24;1H[K     
[24;1H[K:
[24;1H[24;1H[K
[24;1H[K:[24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 

以下是site-start.el trapmp包含的内容供参考:

(require 'tramp)
;(setq tramp-chunksize "500")
(setq tramp-default-method "plink")

(setq exec-path
      (cons
   (expand-file-name "C:/putty_shortcut/")
        exec-path)) 

I have installed a modified Emacs version for Windows XP from Vincent Goulet and I want to run and edit R scripts contained on a remote Unix server using ess-remote. After a lot of searching I am able to connect to a remote R session in the following way:

  1. Open a shell prompt with M-x shell
  2. enter the following command: plink -X -C username@server
  3. After entering password, I start up R in the shell with a simple command R
  4. Assign this as a remote process with command M-x ess-remote

While I am able to interact with R successfully, I always get a double prompt and worse yet, if open a help file for a function, I get garbled text in the same R process buffer, instead of a new buffer opening with legible R help text. How can I get any help buffer to open in a separate window like the usual emacs and R interaction, and how can I get rid of the double-prompts when I execute the shell?

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

c:\Documents and Settings\username>plink -X -C username@remoteserver
plink -X -C username@remoteserver
username@remoteserver's password: 

[username@remoteserver ~]$ R
R

R version 2.11.0 (2010-04-22)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.


Welcome at Sat Jul 24 11:50:45 2010 
> 
> options(STERM='iESS')
options(STERM='iESS')
> 
> x <- c(1,2,3)
> 
> x
[1] 1 2 3
> 
> ?mean(x)
  [?1049h[?1h=[24;1H[Kmean                   package:base                    R        Documentation

Arithmetic Mean

Description:

 Generic function for the (trimmed) arithmetic mean.

Usage:

 mean(x, ...)

 ## Default S3 method:
 mean(x, trim = 0, na.rm = FALSE, ...)

Arguments:

   x: An R object.  Currently there are methods for numeric/logical
      vectors and date, date-time and time interval objects, and
      for data frames all of whose columns have a method.  Complex
      vectors are allowed for 'trim = 0', only.

trim: the fraction (0 to 0.5) of observations to be trimmed from

[24;1H[K:[24;1H[24;1H[K each end of 'x' before the mean is computed. Values of trim
[24;1H[K:
[24;1H[24;1H[K outside that range are taken as the nearest endpoint.

na.rm: a logical value indicating whether 'NA' values should be
      stripped before the computation proceeds.

 ...: further arguments passed to or from other methods.

Value:

 For a data frame, a named vector with the appropriate method being
 applied column by column.

 If 'trim' is zero (the default), the arithmetic mean of the values
 in 'x' is computed, as a numeric or complex vector of length one.
 If 'x' is not logical (coerced to numeric), numeric (including
 integer) or complex, 'NA_real_' is returned, with a warning.

 If 'trim' is non-zero, a symmetrically trimmed mean is computed
 with a fraction of 'trim' observations deleted from each end
 before the mean is computed.

References:

[24;1H[K:[24;1H[24;1H[K     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
[24;1H[K:[24;1H[24;1H[K     Language_.  Wadsworth & Brooks/Cole.
[24;1H[K:
[24;1H[24;1H[K
[24;1H[K:[24;1H[24;1H[KSee Also:
[24;1H[K:
[24;1H[24;1H[K
[24;1H[K:[24;1H[24;1H[K     'weighted.mean', 'mean.POSIXct', 'colMeans' for row and     column
[24;1H[K:
[24;1H[24;1H[K     means.
[24;1H[K:[24;1H[24;1H[K
[24;1H[K:
[24;1H[24;1H[KExamples:
[24;1H[K:[24;1H[24;1H[K
[24;1H[K:
[24;1H[24;1H[K     x <- c(0:10, 50)
[24;1H[K:[24;1H[24;1H[K     xm <- mean(x)
[24;1H[K:
[24;1H[24;1H[K     c(xm, mean(x, trim = 0.10))
[24;1H[K:[24;1H[24;1H[K     
[24;1H[K:
[24;1H[24;1H[K     mean(USArrests, trim = 0.2)
[24;1H[K:[24;1H[24;1H[K     
[24;1H[K:
[24;1H[24;1H[K
[24;1H[K:[24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 
[24;1H[24;1H[K[24;1H[K(END) [24;1H[24;1H[K[24;1H[K(END) 

Here are the contents of site-start.el tramp inclusion for reference:

(require 'tramp)
;(setq tramp-chunksize "500")
(setq tramp-default-method "plink")

(setq exec-path
      (cons
   (expand-file-name "C:/putty_shortcut/")
        exec-path)) 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

行雁书 2024-09-18 02:48:07

对于颜色代码问题,您需要在 shell 模式下启用 ansi-color 支持:

;; Shell mode
(add-hook
 'shell-mode-hook
 (function (lambda ()
             (ansi-color-for-comint-mode-on))))

我在示例中没有看到双提示,但您可以创建一个自定义 shell autoexec 文件来设置自定义提示:

(编辑:啊,你的意思是 R 中的双重 > 提示。我不知道这一点,抱歉,我会在下面留下评论,以防它对某人有用......)

使用的程序来自变量“explicit-shell-file-name”,
或(如果为零)来自 ESHELL 环境变量,
或(如果为零)来自“shell-file-name”。
如果文件“~/.emacs_SHELLNAME”存在,或者“~/.emacs.d/init_SHELLNAME.sh”,它将作为初始输入给出

例如,init_bash.sh 可能包含 export PS1="\n\u@\h \w $ " 用于简单的无色提示。

请参阅 Ch f shell RET 了解更多信息。

For the colour code issue, you need to enable ansi-color support in shell mode:

;; Shell mode
(add-hook
 'shell-mode-hook
 (function (lambda ()
             (ansi-color-for-comint-mode-on))))

I'm not seeing the double-prompt in your examples, but you can create a custom shell autoexec file to set a custom prompt:

(edit: Ah, you meant a double > prompt within R. I don't know about that, sorry. I'll leave the comments below in case it's useful to someone...)

Program used comes from variable `explicit-shell-file-name',
or (if that is nil) from the ESHELL environment variable,
or (if that is nil) from `shell-file-name'.
If a file `~/.emacs_SHELLNAME' exists, or `~/.emacs.d/init_SHELLNAME.sh', it is given as initial input

e.g. init_bash.sh might contain export PS1="\n\u@\h \w $ " for a simple uncoloured prompt.

See C-h f shell RET for more information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文