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 }
Answering you is also a burden without the reprodicible code. I'll pass on that. But I will say that mixing analysis with output in the same function is a terrible habit. Come to the functional side of coding... it is much more re-usable here. On November 30, 2020 12:14:35 AM PST, Steven Yen <styen at 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 at 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.-- Sent from my phone. Please excuse my brevity.
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 <styen at 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 at 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.