s-news
[Top] [All Lists]

Re: Using Objects within a user-defined

To: "Thomas D. Fletcher" <tom.fletcher@cox.net>, S-News List <s-news@lists.biostat.wustl.edu>
Subject: Re: Using Objects within a user-defined
From: "Richard M. Heiberger" <rmh@temple.edu>
Date: Thu, 6 Jan 2005 12:20:01 -0500
Your program works correctly as written.

I am sending back a revised version with comments on the revision.


uni.g <- function(v1, dat, split=c(1, 1, 2, 2), more=F)
{
  a <- bwplot(~v1, data=dat)
  result <- print(a, split=split, more=more)
  invisible(result)
}

## uni.g(VARNAME,DATAFRAME)

tmp <- data.frame(v1=1:10)
uni.g(v1, tmp, more=T)
uni.g(v1, tmp, split=c(2, 2, 2, 2))


1. Spacing for legibility:
   space on both sides of arrow " <- ",
   space after commas,
   indentation to display structure.

2. place split and more as arguments, with default values what
you originally had.

3. return an invisible result to prevent duplicate plots from
displaying.


Rich

<Prev in Thread] Current Thread [Next in Thread>