R Sweave user defined function
I´m writing up a small function giving a combined conditional density and empirical cumulative distribution plot.
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)
}
This works fine, however when I try to sweave it my luck is all out...
<<fig1,fig=T>>=
par(mfrow=c(1,2))
print(cdpl(tre,A,B))
print(cdpl(tre,A,C))
@
Sweave("re.rnw") Writing to file re.tex Processing code chunks ...
1 : echo term verbatim eps pdf (label=fig1)
Error: chunk 1 (label=fig1) Error in model.frame.default(formula = dep ~ indep) : invalid type (list) for variable 'dep'
How can this be when it works allright outside sweave?
//M
而不是附加(导致所有类型的问题)作为cdplot中的数据参数传递数据帧,看看是否有效。
链接地址: http://www.djcxy.com/p/33434.html上一篇: 更高效的R / Sweave / TeXShop工作
下一篇: R Sweave用户定义的功能