[R] Error in Design package: dataset not found for options(datadist)

From: Gad Abraham <gabraham_at_csse.unimelb.edu.au>
Date: Thu, 17 Apr 2008 15:24:20 +1000


Hi,

Design isn't strictly an R base package, but maybe someone can explain the following.

When lrm is called within a function, it can't find the dataset dd:

> library(Design)
> age <- rnorm(30, 50, 10)
> cholesterol <- rnorm(30, 200, 25)
> ch <- cut2(cholesterol, g=5, levels.mean=TRUE)
> fit <- function(ch, age)

+ {
+    d <- data.frame(ch, age)
+    dd <- datadist(d)
+    options(datadist="dd")
+    lrm(ch ~ age, data=d, x=TRUE, y=TRUE)
+ }

> fit(ch, age)

Error in Design(eval(m, sys.parent())) :

   dataset dd not found for options(datadist=)

It works outside a function:
> d <- data.frame(ch, age)
> dd <- datadist(d)

> options(datadist="dd")
> l <- lrm(ch ~ age, data=d, x=TRUE, y=TRUE)

Thanks,
Gad

> sessionInfo()

R version 2.6.2 (2008-02-08)
x86_64-pc-linux-gnu

...

attached base packages:
[1] splines stats graphics grDevices utils datasets methods [8] base

other attached packages:
[1] Design_2.1-1 survival_2.34 Hmisc_3.4-3

loaded via a namespace (and not attached): [1] cluster_1.11.9 grid_2.6.2 lattice_0.17-4 rcompgen_0.1-17

-- 
Gad Abraham
Dept. CSSE and NICTA
The University of Melbourne
Parkville 3010, Victoria, Australia
email: gabraham_at_csse.unimelb.edu.au
web: http://www.csse.unimelb.edu.au/~gabraham

______________________________________________
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.
Received on Thu 17 Apr 2008 - 06:24:51 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Apr 2008 - 14:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive