如何设置 R 使用终端的所有宽度?

如何设置 R 使用终端的所有宽度?

我在终端中运行交互式R,但是它没有使用终端的所有宽度。它只使用了 226 个字符中的 72 个。读取任何以交互方式显示的大量列的数据是非常不舒服的R

我正在urxvt使用debian 9,8.

答案1

?option

 ‘width’: controls the maximum number of columns on a line used in
      printing vectors, matrices and arrays, and when filling by
      ‘cat’.

      Columns are normally the same as characters except in East
      Asian languages.

      You may want to change this if you re-size the window that R
      is running in.  Valid values are 10...10000 with default
      normally 80.  (The limits on valid values are in file
      ‘Print.h’ and can be changed by re-compiling R.)  Some R
      consoles automatically change the value when they are
      resized.

查询值:

R> getOption("width")
[1] 80

要更改该值(添加此值以~/.Rprofile永久更改它):

options("width"=200)

答案2

刚刚找到以下内容。似乎工作正常,但我几乎没有进行测试。

options(width=Sys.getenv("COLUMNS"))
options(setWidthOnResize=TRUE)

前者可以包装到一个函数中以在启动时运行,后者.Rprofile也可以添加到您的函数中。

相关内容