R Sweave用户定义的功能

时间:2010-09-02 18:28:54

标签: r sweave

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

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 verbatim eps pdf(label = fig1)

错误:块1(标签= fig1) model.frame.default中的错误(formula = dep~inmpp):   变量'dep'的无效类型(列表)

当它在外面发挥作用时怎么样?

//中号

1 个答案:

答案 0 :(得分:1)

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