s-news
[Top] [All Lists]

FW: Using Objects within a user-defined

To: "S-News List" <s-news@lists.biostat.wustl.edu>
Subject: FW: Using Objects within a user-defined
From: "Thomas D. Fletcher" <tom.fletcher@cox.net>
Date: Thu, 6 Jan 2005 12:56:38 -0500
Importance: Normal


Thanks Rich,

but, ....

Suppose the data.frame element (i.e., the column or variable) has a
different name (e.g., y1) than the function element (e.g., v1).

Example:

tmp <- data.frame (y1 = rnorm(50))

This renders the same problem that I was encountering before. The object in
the function "v1" was not found when running the program.

The program works in the example Rich provides because the example has the
same variable name in the data.frame as the function. The function I have
tried to write appears to not be generalizable. So, I am still missing
something in the program.

Thanks for any help,
Tom

Rich's revision of the program:

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))




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