Thanks. Will try it.
Have not tried it but I think the following may work:
out$results<-NULL
out$results$ei<-ap
out$results$vi<-vap
All I need is printing by returning out (unless I turn it off). And,
retrieve ap and vap as needed as shown above. Guess I need to read more
about invisible.
On 8/11/2024 10:09 PM, Rui Barradas wrote:> ?s 09:51 de 11/08/2024, Steven Yen escreveu:
>> Hi
>>
>> In the following codes, I had to choose between printing (= TRUE) or
>> deliver something for grab (ei, vi). Is there a way to get both--that
>> is, to print and also have ei and vi for grab? Thanks.
>>
>> Steven
>>
>> ...
>>
>> out<-round(as.data.frame(cbind(ap,se,t,p)),digits)
>> out<-cbind(out,sig)
>> out<-out[!grepl(colnames(zx)[1],rownames(out)),]
>> if(printing){
>> cat("\nAPPs of bivariate ordered probit probabilities",
>> ???? "\nWritten by Steven T. Yen (Last update: 08.11.24)",
>> ???? "\ny1.level=",???? y1.level,
>> ???? "? y2.level=",???? y2.level,
>> ???? "\njoint12 =",???? joint12,
>> ???? "\nmarg1 =",?????? marg1,
>> ???? "\nmarg2 =",?????? marg2,
>> ???? "\ncond12 =",????? cond12,
>> ???? "\ncond21 =",????? cond21,
>> ???? "\nCovariance matrix:",vb.method,
>> ???? "\nWeighted =",??????? weighted,
>> ???? "\nAt means =",??????? mean,
>> ???? "\nProb x 100 =",????? times100,
>> ???? "\ntesting ="????? ,?? testing,
>> ???? "\nuse_bb_and_vbb = ",use_bb_and_vbb,
>> ???? "\nsample size =",???? length(y1),"\n")
>> if (!resampling) cat("\nSEs by delta method","\n")
>> if? (resampling) cat("\nSEs K-R resampling
with",ndraws,"draws\n")
>> return(out)
>> } else {
>> invisible(list("ei"=ap,"vi"=vap))
>>
>> ______________________________________________
>> 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.
>
> Hello,
>
> Maybe change the end of the code to return a bigger list.
>
>
> ll <- list(out = out, ei = ap, vi = vap)
> return(ll)
> } else {
> invisible(list("ei"=ap,"vi"=vap))
>
>
> Hope this helps,
>
> Rui Barradas
>
>
>