Re: [R] Trapping option settings

2012-07-18 Thread David A Vavra
Jim,

Thanks. 

It wasn't sure if merely overriding the options function by placing one in
the global environment would guarantee it would be the one actually called.
In any case, I didn't know how to identify the caller. This is quite helpful
and looks promising. I'll give it a try.

DAV




-Original Message-
From: jim holtman [mailto:jholt...@gmail.com] 
Sent: Monday, July 16, 2012 9:59 PM
To: David A Vavra
Cc: r-help@r-project.org
Subject: Re: [R] Trapping option settings

Here is one way by redefining 'options' so you can check for 'width'
and then call the 'options' in 'base':


 options -  # define 'options' in Global
+ function(...)
+ {
+ args - list(...)  # get arguments
+ if ('width' %in% names(args)){  # see if 'width' is in them
+ .caller - sys.calls()  # get where called from
+ if (length(.caller) == 1)  # called from command line
+ .caller - Rgui
+ else .caller - as.character(.caller[[length(.caller) - 1]])[1]
+ cat(width being changed:, args[['width']], Called from,
.caller, '\n')
+ }
+ base::options(...)  # call the real options
+ }


 options(width = 123) # test at command line
width being changed: 123 Called from Rgui
 f.myfunc - function() options(width = 456)  # within a function
 f.myfunc()
width being changed: 456 Called from f.myfunc





On Mon, Jul 16, 2012 at 9:01 PM, David A Vavra dava...@verizon.net wrote:
 Something has been changing the setting the width option to 1 and not
 resetting it. It does this intermittently. What I would like to do is trap
 changing the setting so I can determine where the change is occurring and
 hopefully fix it.

 Is there any easy way to do this?

 __
 R-help@r-project.org mailing list
 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.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

__
R-help@r-project.org mailing list
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.


Re: [R] Trapping option settings

2012-07-18 Thread William Dunlap
Try using trace(), as in
  trace(options, quote(print(as.list(sys.calls()

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
 Behalf Of David A Vavra
 Sent: Wednesday, July 18, 2012 1:00 PM
 To: 'jim holtman'
 Cc: r-help@r-project.org
 Subject: Re: [R] Trapping option settings
 
 Jim,
 
 Thanks.
 
 It wasn't sure if merely overriding the options function by placing one in
 the global environment would guarantee it would be the one actually called.
 In any case, I didn't know how to identify the caller. This is quite helpful
 and looks promising. I'll give it a try.
 
 DAV
 
 
 
 
 -Original Message-
 From: jim holtman [mailto:jholt...@gmail.com]
 Sent: Monday, July 16, 2012 9:59 PM
 To: David A Vavra
 Cc: r-help@r-project.org
 Subject: Re: [R] Trapping option settings
 
 Here is one way by redefining 'options' so you can check for 'width'
 and then call the 'options' in 'base':
 
 
  options -  # define 'options' in Global
 + function(...)
 + {
 + args - list(...)  # get arguments
 + if ('width' %in% names(args)){  # see if 'width' is in them
 + .caller - sys.calls()  # get where called from
 + if (length(.caller) == 1)  # called from command line
 + .caller - Rgui
 + else .caller - as.character(.caller[[length(.caller) - 1]])[1]
 + cat(width being changed:, args[['width']], Called from,
 .caller, '\n')
 + }
 + base::options(...)  # call the real options
 + }
 
 
  options(width = 123) # test at command line
 width being changed: 123 Called from Rgui
  f.myfunc - function() options(width = 456)  # within a function
  f.myfunc()
 width being changed: 456 Called from f.myfunc
 
 
 
 
 
 On Mon, Jul 16, 2012 at 9:01 PM, David A Vavra dava...@verizon.net wrote:
  Something has been changing the setting the width option to 1 and not
  resetting it. It does this intermittently. What I would like to do is trap
  changing the setting so I can determine where the change is occurring and
  hopefully fix it.
 
  Is there any easy way to do this?
 
  __
  R-help@r-project.org mailing list
  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.
 
 
 
 --
 Jim Holtman
 Data Munger Guru
 
 What is the problem that you are trying to solve?
 Tell me what you want to do, not how you want to do it.
 
 __
 R-help@r-project.org mailing list
 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.

__
R-help@r-project.org mailing list
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.


Re: [R] Trapping option settings

2012-07-18 Thread David A Vavra
Thanks. Also helpful. 

DAV


-Original Message-
From: William Dunlap [mailto:wdun...@tibco.com] 
Sent: Wednesday, July 18, 2012 4:20 PM
To: David A Vavra; 'jim holtman'
Cc: r-help@r-project.org
Subject: RE: [R] Trapping option settings

Try using trace(), as in
  trace(options, quote(print(as.list(sys.calls()

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
 Behalf Of David A Vavra
 Sent: Wednesday, July 18, 2012 1:00 PM
 To: 'jim holtman'
 Cc: r-help@r-project.org
 Subject: Re: [R] Trapping option settings
 
 Jim,
 
 Thanks.
 
 It wasn't sure if merely overriding the options function by placing one in
 the global environment would guarantee it would be the one actually
called.
 In any case, I didn't know how to identify the caller. This is quite
helpful
 and looks promising. I'll give it a try.
 
 DAV
 
 
 
 
 -Original Message-
 From: jim holtman [mailto:jholt...@gmail.com]
 Sent: Monday, July 16, 2012 9:59 PM
 To: David A Vavra
 Cc: r-help@r-project.org
 Subject: Re: [R] Trapping option settings
 
 Here is one way by redefining 'options' so you can check for 'width'
 and then call the 'options' in 'base':
 
 
  options -  # define 'options' in Global
 + function(...)
 + {
 + args - list(...)  # get arguments
 + if ('width' %in% names(args)){  # see if 'width' is in them
 + .caller - sys.calls()  # get where called from
 + if (length(.caller) == 1)  # called from command line
 + .caller - Rgui
 + else .caller - as.character(.caller[[length(.caller) - 1]])[1]
 + cat(width being changed:, args[['width']], Called from,
 .caller, '\n')
 + }
 + base::options(...)  # call the real options
 + }
 
 
  options(width = 123) # test at command line
 width being changed: 123 Called from Rgui
  f.myfunc - function() options(width = 456)  # within a function
  f.myfunc()
 width being changed: 456 Called from f.myfunc
 
 
 
 
 
 On Mon, Jul 16, 2012 at 9:01 PM, David A Vavra dava...@verizon.net
wrote:
  Something has been changing the setting the width option to 1 and
not
  resetting it. It does this intermittently. What I would like to do is
trap
  changing the setting so I can determine where the change is occurring
and
  hopefully fix it.
 
  Is there any easy way to do this?
 
  __
  R-help@r-project.org mailing list
  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.
 
 
 
 --
 Jim Holtman
 Data Munger Guru
 
 What is the problem that you are trying to solve?
 Tell me what you want to do, not how you want to do it.
 
 __
 R-help@r-project.org mailing list
 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.

__
R-help@r-project.org mailing list
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.


[R] Trapping option settings

2012-07-16 Thread David A Vavra
Something has been changing the setting the width option to 1 and not
resetting it. It does this intermittently. What I would like to do is trap
changing the setting so I can determine where the change is occurring and
hopefully fix it.

Is there any easy way to do this?

__
R-help@r-project.org mailing list
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.


Re: [R] Trapping option settings

2012-07-16 Thread jim holtman
Here is one way by redefining 'options' so you can check for 'width'
and then call the 'options' in 'base':


 options -  # define 'options' in Global
+ function(...)
+ {
+ args - list(...)  # get arguments
+ if ('width' %in% names(args)){  # see if 'width' is in them
+ .caller - sys.calls()  # get where called from
+ if (length(.caller) == 1)  # called from command line
+ .caller - Rgui
+ else .caller - as.character(.caller[[length(.caller) - 1]])[1]
+ cat(width being changed:, args[['width']], Called from,
.caller, '\n')
+ }
+ base::options(...)  # call the real options
+ }


 options(width = 123) # test at command line
width being changed: 123 Called from Rgui
 f.myfunc - function() options(width = 456)  # within a function
 f.myfunc()
width being changed: 456 Called from f.myfunc





On Mon, Jul 16, 2012 at 9:01 PM, David A Vavra dava...@verizon.net wrote:
 Something has been changing the setting the width option to 1 and not
 resetting it. It does this intermittently. What I would like to do is trap
 changing the setting so I can determine where the change is occurring and
 hopefully fix it.

 Is there any easy way to do this?

 __
 R-help@r-project.org mailing list
 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.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

__
R-help@r-project.org mailing list
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.