Skip to content

Current Terminal (console) width

11 messages · Ben Tupper, Jared Studyvin, David L Carlson +4 more

#
Hello,

On a non Windows OS the following command: Sys.getenv("COLUMNS")
Will return the current width of the R terminal (console) but this does not
work on a Windows OS.

Does anyone know equivelant R code when install on a Windows OS?

I'm using WIndows 10 Pro Version: 1607; R 3.3.2

Thanks,

*Jared Studyvin, PhD *
*Statistician*


Environmental & Statistical Consultants
200 S. Second Street
Laramie, WY 82070
(307) 721-3179
jstudyvin at west-inc.com
www.west-inc.com

*Follow WEST: *Facebook
<http://www.facebook.com/pages/Western%E2%80%90EcoSystems%E2%80%90Technology%E2%80%90WESTInc/125604770807646>
, Twitter <http://twitter.com/WestEcoSystems>, Linked In
<http://www.linkedin.com/company/1458419>, Join our Mailing list
<http://visitor.r20.constantcontact.com/manage/optin/ea?v=001qrD4A3S5xJ5KgMyelH9jyw%3D%3D>

CONFIDENTIALITY NOTICE:  This message and any accompanyi...{{dropped:19}}
#
Hi,

Have you looked at
and does that get at what you need?

Ben
Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org
#
Ben,

That options control is about the size of what is printed. I'm looking for
the actual size of the window in real time.

options('width') ## returns 80
resize the terminal window
options('width') ## returns 80

Sys.getenv('COLUMNS') ## returns current window width
resize the terminal window
Sys.getenv('COLUMNS') ## returns a different value

This however does not work on a Windows OS.

Thanks,




*Jared Studyvin, PhD *
*Statistician*


Environmental & Statistical Consultants
200 S. Second Street
Laramie, WY 82070
(307) 721-3179
jstudyvin at west-inc.com
www.west-inc.com

*Follow WEST: *Facebook
<http://www.facebook.com/pages/Western%E2%80%90EcoSystems%E2%80%90Technology%E2%80%90WESTInc/125604770807646>
, Twitter <http://twitter.com/WestEcoSystems>, Linked In
<http://www.linkedin.com/company/1458419>, Join our Mailing list
<http://visitor.r20.constantcontact.com/manage/optin/ea?v=001qrD4A3S5xJ5KgMyelH9jyw%3D%3D>

CONFIDENTIALITY NOTICE:  This message and any accompanying communications
are covered by the Electronic Communications Privacy Act, 18 U.S.C. ??
2510-2521, and contain information that is privileged, confidential or
otherwise protected from disclosure.  If you are not the intended recipient
or an agent responsible for delivering the communication to the intended
recipient, you are hereby notified that you have received this
communication in error.  Dissemination, distribution or copying of this
e-mail or the information herein by anyone other than the intended
recipient, or an employee or agent responsible for delivering the message
to the intended recipient, is prohibited.  If you have received this
communication in error, please notify us immediately by e-mail and delete
the original message.  Thank you.

P Please consider the environment before printing.
On Fri, Jan 20, 2017 at 8:48 AM, Ben Tupper <btupper at bigelow.org> wrote:

            

  
  
#
I cannot replicate that on Windows 8 (64 bit or 32 bit):
$width
[1] 90

# Drag the window to resize, then:
$width
[1] 124

-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Jared Studyvin
Sent: Friday, January 20, 2017 10:18 AM
To: Ben Tupper <btupper at bigelow.org>
Cc: r-help mailing list <r-help at r-project.org>
Subject: Re: [R] Current Terminal (console) width

Ben,

That options control is about the size of what is printed. I'm looking for
the actual size of the window in real time.

options('width') ## returns 80
resize the terminal window
options('width') ## returns 80

Sys.getenv('COLUMNS') ## returns current window width
resize the terminal window
Sys.getenv('COLUMNS') ## returns a different value

This however does not work on a Windows OS.

Thanks,




*Jared Studyvin, PhD *
*Statistician*


Environmental & Statistical Consultants
200 S. Second Street
Laramie, WY 82070
(307) 721-3179
jstudyvin at west-inc.com
www.west-inc.com

*Follow WEST: *Facebook
<http://www.facebook.com/pages/Western%E2%80%90EcoSystems%E2%80%90Technology%E2%80%90WESTInc/125604770807646>
, Twitter <http://twitter.com/WestEcoSystems>, Linked In
<http://www.linkedin.com/company/1458419>, Join our Mailing list
<http://visitor.r20.constantcontact.com/manage/optin/ea?v=001qrD4A3S5xJ5KgMyelH9jyw%3D%3D>

CONFIDENTIALITY NOTICE:  This message and any accompanying communications
are covered by the Electronic Communications Privacy Act, 18 U.S.C. ??
2510-2521, and contain information that is privileged, confidential or
otherwise protected from disclosure.  If you are not the intended recipient
or an agent responsible for delivering the communication to the intended
recipient, you are hereby notified that you have received this
communication in error.  Dissemination, distribution or copying of this
e-mail or the information herein by anyone other than the intended
recipient, or an employee or agent responsible for delivering the message
to the intended recipient, is prohibited.  If you have received this
communication in error, please notify us immediately by e-mail and delete
the original message.  Thank you.

P Please consider the environment before printing.
On Fri, Jan 20, 2017 at 8:48 AM, Ben Tupper <btupper at bigelow.org> wrote:

            
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
#
David,

When using native R GUI that does work because the option is checked to do
that. See Edit -> GUI Preferences...

I'm looking for the R code that will do that same thing so when R is not
being run in the native GUI I can ensure that same behavior.

Thanks,


*Jared Studyvin, PhD *
*Statistician*


Environmental & Statistical Consultants
200 S. Second Street
Laramie, WY 82070
(307) 721-3179
jstudyvin at west-inc.com
www.west-inc.com

*Follow WEST: *Facebook
<http://www.facebook.com/pages/Western%E2%80%90EcoSystems%E2%80%90Technology%E2%80%90WESTInc/125604770807646>
, Twitter <http://twitter.com/WestEcoSystems>, Linked In
<http://www.linkedin.com/company/1458419>, Join our Mailing list
<http://visitor.r20.constantcontact.com/manage/optin/ea?v=001qrD4A3S5xJ5KgMyelH9jyw%3D%3D>

CONFIDENTIALITY NOTICE:  This message and any accompanying communications
are covered by the Electronic Communications Privacy Act, 18 U.S.C. ??
2510-2521, and contain information that is privileged, confidential or
otherwise protected from disclosure.  If you are not the intended recipient
or an agent responsible for delivering the communication to the intended
recipient, you are hereby notified that you have received this
communication in error.  Dissemination, distribution or copying of this
e-mail or the information herein by anyone other than the intended
recipient, or an employee or agent responsible for delivering the message
to the intended recipient, is prohibited.  If you have received this
communication in error, please notify us immediately by e-mail and delete
the original message.  Thank you.

P Please consider the environment before printing.
On Fri, Jan 20, 2017 at 9:29 AM, David L Carlson <dcarlson at tamu.edu> wrote:

            

  
  
#
David et al:

from ?options

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

[as Jared said]

...
Some R consoles automatically change the value when they are resized."

So this behavior depends on the unstated by both of you console in
which R is running.


Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Fri, Jan 20, 2017 at 8:29 AM, David L Carlson <dcarlson at tamu.edu> wrote:
#
The answer is UI-specific.

In the supplied-by-R-core Windows GUI for R, options("width") is the
current width of the command window.  If you run R in a cmd.exe window
instead of the GUI you can get the width of the cmd window by doing
some string manipulations on the output of shell("mode con",
intern=TRUE).  E.g.,
as.integer(sub("^.* ", "", grep(value=TRUE, "Columns:", shell("mode
con", intern=TRUE))))

(Setting options(width=120) when using the cmd window does not seem to
affect the input echoing - it seems to always be 80 characters.)
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Jan 20, 2017 at 8:17 AM, Jared Studyvin <jstudyvin at west-inc.com> wrote:
#
On Fri, Jan 20, 2017 at 11:52 AM, Jared Studyvin <jstudyvin at west-inc.com> wrot:
You still have not told use where it IS being run. That might be
useful information.

Best,
Ista
#
Ista,

I use R through Emacs. I'm trying to get this to work there. At a more
basic level I'm disappointed that when I use R on my Mac I can get this
information but when I use R on Windows I can not.

Thanks,

*Jared Studyvin, PhD *
*Statistician*


Environmental & Statistical Consultants
200 S. Second Street
Laramie, WY 82070
(307) 721-3179
jstudyvin at west-inc.com
www.west-inc.com

*Follow WEST: *Facebook
<http://www.facebook.com/pages/Western%E2%80%90EcoSystems%E2%80%90Technology%E2%80%90WESTInc/125604770807646>
, Twitter <http://twitter.com/WestEcoSystems>, Linked In
<http://www.linkedin.com/company/1458419>, Join our Mailing list
<http://visitor.r20.constantcontact.com/manage/optin/ea?v=001qrD4A3S5xJ5KgMyelH9jyw%3D%3D>

CONFIDENTIALITY NOTICE:  This message and any accompanying communications
are covered by the Electronic Communications Privacy Act, 18 U.S.C. ??
2510-2521, and contain information that is privileged, confidential or
otherwise protected from disclosure.  If you are not the intended recipient
or an agent responsible for delivering the communication to the intended
recipient, you are hereby notified that you have received this
communication in error.  Dissemination, distribution or copying of this
e-mail or the information herein by anyone other than the intended
recipient, or an employee or agent responsible for delivering the message
to the intended recipient, is prohibited.  If you have received this
communication in error, please notify us immediately by e-mail and delete
the original message.  Thank you.

P Please consider the environment before printing.
On Fri, Jan 20, 2017 at 10:29 AM, Ista Zahn <istazahn at gmail.com> wrote:

            

  
  
#
Hi Jared,
On Jan 20, 2017 1:36 PM, "Jared Studyvin" <jstudyvin at west-inc.com> wrote:
Ista,

I use R through Emacs. I'm trying to get this to work there.


Here is how ESS calculates the width of the comint buffer:

https://github.com/emacs-ess/ESS/blob/e21af4d2a09c6cb6061e8cd9f0f5cacadedcccc3/lisp/ess-inf.el#L2449

This works cross-platform.

At a more basic level I'm disappointed that when I use R on my Mac I can
get this information but when I use R on Windows I can not.


Sounds like an issue that should be taken up with microsoft.


Thanks,

*Jared Studyvin, PhD *
*Statistician*


Environmental & Statistical Consultants
200 S. Second Street
Laramie, WY 82070
(307) 721-3179
jstudyvin at west-inc.com
www.west-inc.com

*Follow WEST: *Facebook
<http://www.facebook.com/pages/Western%E2%80%90EcoSystems%E2%80%90Technology%E2%80%90WESTInc/125604770807646>
, Twitter <http://twitter.com/WestEcoSystems>, Linked In
<http://www.linkedin.com/company/1458419>, Join our Mailing list
<http://visitor.r20.constantcontact.com/manage/optin/ea?v=001qrD4A3S5xJ5KgMyelH9jyw%3D%3D>

CONFIDENTIALITY NOTICE:  This message and any accompanying communications
are covered by the Electronic Communications Privacy Act, 18 U.S.C. ??
2510-2521, and contain information that is privileged, confidential or
otherwise protected from disclosure.  If you are not the intended recipient
or an agent responsible for delivering the communication to the intended
recipient, you are hereby notified that you have received this
communication in error.  Dissemination, distribution or copying of this
e-mail or the information herein by anyone other than the intended
recipient, or an employee or agent responsible for delivering the message
to the intended recipient, is prohibited.  If you have received this
communication in error, please notify us immediately by e-mail and delete
the original message.  Thank you.

P Please consider the environment before printing.
On Fri, Jan 20, 2017 at 10:29 AM, Ista Zahn <istazahn at gmail.com> wrote:

            

  
  
#
For clarity, maintenance of the COLUMNS environment variable is a feature of certain terminal drivers, and is therefore an operating system feature, not an R feature.