Learn R Programming

setwidth (version 1.1.0)

setwidth-package: Automatically set the value of options("width") when the terminal emulator is resized

Description

This package automatically sets options("width") when using R in terminal windows on OSX primarily (but on Unix-like OSes too) and resizing the terminal (e.g., iTerm2 on OSX). It may be useful if options(setWidthOnResize=TRUE) does not work properly for any reason.

This package should not be used with graphical interfaces such as RStudio, RKward, JGR, Rcmdr, or any other interface that handles R output on its own, or when using R via remote sessions (like via a ssh connection, for example). The functions only work if R runs interactively in a terminal emulator. The terminal emulator may be called by a text editor like Vim, Gedit, Kate, or Geany.

Arguments

Author

Jakson Alves de Aquino and Dominique-Laurent Couturier

Details

The package will print information on the R Console if its setwidth.verbose option was set to a numeric value bigger than zero:


  options(setwidth.verbose = 1) # Print startup message
  options(setwidth.verbose = 2) # Print error message when unable to set width
  options(setwidth.verbose = 3) # Print width value
  

The package does not have any user visible R function. When it is loaded, the SIGWINCH signal starts to be handled by a C function that updates the value of options("width"). The handle will not be activated if interactive() == FALSE or the value of the environment variable TERM is either empty or "dumb".

To manually test whether the package is working properly on your system you may repeatedly resize the terminal emulator and print a long vector, like 1:300.

To disable the automatic setting of options("width") do:


  detach("package:setwidth", unload = TRUE)
  

See Also

The package colorout colorizes R output when running in a unix/osx terminal emulators.

Examples

Run this code
options(setwidth.verbose = 1)
print(getOption("width"))

Run the code above in your browser using DataLab