I use solve(A,b) inside my function, myfun2; it works fine when I return one value or a list. I want use the return values in ggplot as below: ggplot(data.frame( x=c(0.1,0.8)),aes(x=x))+stat_function(fun=myfun.2,geom="line") I get a blank graph. Would greatly appreciate help! Thanks.
Here are my codes: p.lm<-0.05 ##to initialze only p.lh<-0.1 p.ll<-1-p.lm-p.lh p.ml<-0.3 p.mh<-0.1 p.mm<-1-p.ml-p.mh p.hl<-0.05 p.hm<-0.5 p.hh<-1-p.hl-p.hm myfun.5<-function(xvar){ y<-numeric(2) p.lm<-xvar A<-matrix(c(p.lm+p.lh+p.hl,p.hl-p.ml,p.hm-p.lm,p.ml+p.mh+p.hm),nrow=2,byrow = TRUE) b<-c(p.hl,p.hm) y<-solve(A,b) z<-list(y[1],y[2],1-y[1]-y[2]) z[1] } g.2<-ggplot(data.frame( x=c(0.1,0.8)),aes(x=x))+stat_function(fun=myfun.5,geom="line") g.2 -- Professor of Family Medicine Boston University Tel: 617-414-6221, Fax:617-414-3345 emails: chett...@gmail.com,vche...@bu.edu [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.