It's easier that you think; Fancyhist <- function(x, break=NULL, ...) { # first, process x into xprocess somehow, then ...
if (is.null(breaks)) { # define the histogram breaks somehow, then call hist: } hist(xprocess, break=breaks, ...) } /H On Tue, Mar 29, 2011 at 10:47 AM, Cable, Samuel B Civ USAF AFMC AFRL/RVBXI <samuel.ca...@hanscom.af.mil> wrote: > I would like to do something like the following: > > Fancyhist<-function(x,...) { > > # first, process x into xprocess somehow, then ... > > if (is.null(breaks)) { # yes, I know this is wrong > # define the histogram breaks somehow, then call hist: > hist(xprocess,breaks=breaks,...) > } else { > # use breaks give in calling argument > hist(xprocess,...) > } > > } > > But, those of you who know R better than I do have already spotted that > "is.null(breaks)" just won't work. Neither does "exists" or "missing". > > I can think of ways to do this involving new arguments with new names -- > like "histbreaks" or something -- but that seems inelegant. > > Is there a way to do what I am trying to do here? > > Thanks. > > ______________________________________________ > 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.