How to increase the number of columns using R in Linux

R

R Problem Overview


This may seem menial, but it affects my productivity. I am using R in terminal mode on Linux. Unlike the Windows IDE, Linux limits the number of columns to 80, thus making harder the inspection of data sets. Is there a way to set the max number of columns?

R Solutions


Solution 1 - R

Here is a function I have in my ~/.Rprofile file:

wideScreen <- function(howWide=Sys.getenv("COLUMNS")) {
  options(width=as.integer(howWide))
}

Calling the function without the howWide argument sets the column to be the width of your terminal. You can optionally pass in the argument to set the width to an arbitrary number of your choosing.

Almost like Josh's suggestion, but less magic :-)

Solution 2 - R

Set it with something like

options("width"=200)

which is in fact what I have in ~/.Rprofile. See help(options) for details.

Solution 3 - R

Stealing an idea from Brendan O'Connor's util.R (http://github.com/brendano/dlanalysis/blob/master/util.R), you can get your R terminal to set the default width using the stty command. Remunging his script to work on linux, you get the following sexy 1 liner:

options(width=as.integer(system("stty -a | head -n 1 | awk '{print $7}' | sed 's/;//'", intern=T)))

Solution 4 - R

Insert this line to your ~/.Rprofile

options(width=system("tput cols", intern=TRUE))

Solution 5 - R

I use this:

wideScreen <- function(howWide=as.numeric(strsplit(system('stty size', intern=T), ' ')[[1]])[2]) {
   options(width=as.integer(howWide))
}

Because the COLUMNS environment variable, and tset, aren't updated when the window is resized, but stty size is.

Solution 6 - R

You can use the TK gui, I think the option was --ui=TK or something like this.

Or is it a hard requirement to use it in the terminal?

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiongappyView Question on Stackoverflow
Solution 1 - RSteve LianoglouView Answer on Stackoverflow
Solution 2 - RDirk EddelbuettelView Answer on Stackoverflow
Solution 3 - RJosh ReichView Answer on Stackoverflow
Solution 4 - RplhnView Answer on Stackoverflow
Solution 5 - RMartin C. MartinView Answer on Stackoverflow
Solution 6 - RfortranView Answer on Stackoverflow