3

我正在编写一个小函数,给出组合条件密度和经验累积分布图。

cdpl<-function(df,dep,indep){
    attach(df)

    cdplot(dep~indep,xlab=deparse(substitute(indep)),ylab=deparse(substitute(dep)))
    g<-indep
    ec<-ecdf(indep)
    lines(knots(ec),as.numeric(names(table(ec(g)))),col="red",lw=3)
    detach(df)
    }

这很好用,但是当我尝试编织它时,我的运气已经全部耗尽......

<<fig1,fig=T>>=
par(mfrow=c(1,2))
print(cdpl(tre,A,B))
print(cdpl(tre,A,C))
@

Sweave("re.rnw") 写入文件 re.tex 处理代码块 ...

1 : echo term 逐字 eps pdf (label=fig1)

错误:块 1 (label=fig1) model.frame.default(formula = dep ~ indep) 中的错误:变量“dep”的类型(列表)无效

当它在 sweave 之外可以正常工作时,这怎么可能呢?

//M

4

1 回答 1

1

而不是附加(导致所有类型的问题)将数据框作为数据参数传递给 cdplot 并查看是否有效。

于 2010-09-02T19:02:32.383 回答