TOPIC: Why some returned values do not automatically print. Again, not seeing the internals, my guess is the function returned not the expected but "invisible(expected)" which just marks it as not to be automatically printed.
So if you want it printed, ask for it explicitly as in: print(me.probit(obj)) What you did was to copy the object and then the copy does not keep the invisibility so when invoked, gets the default print action. -----Original Message----- From: R-help <r-help-boun...@r-project.org> On Behalf Of Steven Yen Sent: Monday, November 30, 2020 4:42 AM To: Jim Lemon <drjimle...@gmail.com>; r-help mailing list <r-help@r-project.org> Subject: Re: [R] Printing upon calling a function Thanks. I know, my point was on why I get something printed by simply doing line 1 below and at other occasions had to do line 2. me.probit(obj) v<-me.probit(obj); v On 2020/11/30 下午 05:33, Jim Lemon wrote: > Hi Steven, > You seem to be assigning the result of me.oprobit(obj) to v instead of > printing it. By appending ";v" tp that command line, you implicitly > call "print". > > Jim > > On Mon, Nov 30, 2020 at 7:15 PM Steven Yen <st...@ntu.edu.tw> wrote: >> I hope I can get away without presenting a replicable set of codes >> because doing so would impose burdens. >> >> I call a function which return a data frame, with the final line >> >> return(out) >> >> In one case the data frame gets printed (similar to a regression >> printout), with simply a call >> >> me.probit(obj) >> >> In another case with a similar function, I could not get the results >> printed and the only way to print is to do the following: >> >> v<-me.oprobit(obj); v >> >> This is a puzzle, and I hope to find some clues. Thanks to all. >> >> My function looks like the following: >> >> me.oprobit0 <- function(obj,mean=FALSE,vb.method,jindex=NA, >> resampling=FALSE,ndraws=100,mc.method=1,times100=TRUE, >> Stata.mu=FALSE,testing=FALSE,digits=3){ >> ... >> return(out) # out is a data frame >> } >> >> ______________________________________________ >> 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. ______________________________________________ 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. Scanned by McAfee and confirmed virus-free. Find out more here: https://bit.ly/2zCJMrO ______________________________________________ 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.