The problem is illustrated below: line<-function(x,y) { fit<-lm(y~x) fit } func<-function() { x<-c(1,2,3,4) y<-c(1.1,2,3,4) for(i in 1:2) { fit<-line(x,y) summary(fit) } } Why don't I get two printed summaries when I run func()? How to make it work? (In reality I will be getting different summaries of different data sets using this loop) Thanks very much for any help. Bill Simpson -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Bill Simpson <wsi at gcal.ac.uk> writes:> The problem is illustrated below: > > line<-function(x,y) > { > fit<-lm(y~x) > fit > } > > func<-function() > { > x<-c(1,2,3,4) > y<-c(1.1,2,3,4) > > for(i in 1:2) > { > fit<-line(x,y) > summary(fit) > } > } > > Why don't I get two printed summaries when I run func()? How to make it > work? (In reality I will be getting different summaries of different data > sets using this loop)You haven't asked to have them printed... Use print(summary(fit)) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._