[R] Trapping option settings

jim holtman jholtman at gmail.com
Tue Jul 17 03:59:14 CEST 2012


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 <davavra at verizon.net> wrote:
> Something has been changing the setting the width option to 10000 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 at 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.



More information about the R-help mailing list