[R] cat in a subroutine

Steven T. Yen @tyen @end|ng |rom ntu@edu@tw
Fri Oct 14 03:09:35 CEST 2022


Hello, Oh Lord, yes, I had a function called "cat", with argument "j". 
That was very dumb.

Renaming function cat resolved the problem. I had lived with this 
problem too long---avoiding printing with cat altogether in this 
program. Thanks to all-----Bill, Iva, Jim, Erin, Andrew for help!

On 10/13/2022 10:30 PM, Bill Dunlap wrote:
> Do you have another function called "cat" in scope? (with an argument 
> called "j")?  Before calling cat("...") call print(cat) and 
> print(find("cat")).
>
> -Bill
>
>
> On Thu, Oct 13, 2022 at 12:35 AM Steven T. Yen <styen using ntu.edu.tw> wrote:
>
>     I have had an issue with printing (with cat) in a subroutine for
>     which I
>     do not have a applicable example, but I am still hoping to get some
>     help. In the following, the first block of code works fine.
>
>     ...
>
>     t<-abs(me)/se; p<-2*(1-pt(t,nrow(x)))
>     sig<-my.sig.levels(p)
>     out<-data.frame(round(cbind(me,se,t,p),digits)); out<-cbind(out,sig)
>     rownames(out)<-names(me)
>     colnames(out)<-c("est","se","t","p","sig")
>     j<-grep(".one\\b",rownames(out))
>     out<-out[-j,]
>     return(out)
>     }
>
>     But as soon as I insert lines to print (cat) soething simple, it
>     spits
>     out message that appears to be nonsence (unrelated). Any idea. Please
>     help. Thanks.
>
>     t<-abs(me)/se; p<-2*(1-pt(t,nrow(x)))
>     sig<-my.sig.levels(p)
>     out<-data.frame(round(cbind(me,se,t,p),digits)); out<-cbind(out,sig)
>     rownames(out)<-names(me)
>     colnames(out)<-c("est","se","t","p","sig")
>     cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
>     Probabilities",
>          "\n\nlogistic =",logistic)
>     j<-grep(".one\\b",rownames(out))
>     out<-out[-j,]
>     return(out)
>     }
>
>     In this particular case, the error message was as follows:
>
>     Error in cat("\nMarginal and Discrete Effects of Gen Ordered Logit /
>     Probit Probabilities",  :
>        unused argument (logistic)
>
>     I have printed this way in numerous routines without problem and
>     do not
>     see why this is happending.
>
>     ______________________________________________
>     R-help using 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
>     <http://www.R-project.org/posting-guide.html>
>     and provide commented, minimal, self-contained, reproducible code.
>
	[[alternative HTML version deleted]]



More information about the R-help mailing list