[R] Error in model.frame

Ross Boylan ross at biostat.ucsf.edu
Sat Aug 16 01:03:26 CEST 2003


I am getting an error that I don't understand, and wonder if anyone
could explain what's going on.  I call a function defined thus:

clogit.rds<-function(formula,data,extra.data,response.prob,
                 na.action=getOption("na.action"),subset=NULL,
                 control=coxph.control()){
    method="exact"  # only option for now
    mf<-match.call()
    mf[[1]]<-as.name("model.frame")
    mf$method<-mf$control<-NULL
    mfn<-mf

    mfn$na.action<-"I"
    mfn$subset<-NULL
    nrows<-NROW(eval(mfn,parent.frame()))
etc.
At the eval on the last line, I get

Error in model.frame(formula, rownames, variables, varnames, extras,
extranames,  : 
	variable lengths differ

This is puzzling for two reasons.  First, I don't understand where the
arguments given in the error message are coming from.  They are not in
my function definition or call, and they do not seem to be the arguments
to model.frame either.

Second, I don't know why it's not working!  This is modified from clogit
in survival, and that works fine.  I've added two arguments, extra.data
(which is just a column of the data) and response.prob.  The latter has
different dimensions (response.prob = c(1, 1), in fact), but nothing in
the description of model.frame suggests that should be a problem.

model.frame itself is a wrapper on a primitive, so I can't really debug
into it.

Background:

Running R 1.7.1-1 on Debian Gnu/Linux.

In case it matters, the code I'm running was produced by hacking the
survival package, running R CMD check, and then loading the package from
the test directory that created:
library("survival", lib.loc="/home/ross/src/survival.Rcheck")

The clogit command seems to run fine.

One of the variables in the data.frame is name proband, which I notice
gets highlighted by ESS.




More information about the R-help mailing list