Thanks Erin. No. Removing the second line (so that cat simply prints something else), cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit Probabilities") #??? "\n\nlogistic =",logistic) I get yet another nonsense: Error in cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit Probabilities") : ? argument "j" is missing, with no default > On 10/13/2022 3:37 PM, Erin Hodgess wrote:> Hi?Steven: > > Do you have a variable called logistic, please?? I think that might be > the culprit. > > Thanks, > Erin > > On Thu, Oct 13, 2022 at 1:35 AM Steven T. Yen <styen at 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 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 > <http://www.R-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > > -- > Erin Hodgess, PhD > mailto: erinm.hodgess at gmail.com[[alternative HTML version deleted]]
All right. Are these lines of code part of a larger function, please? Is that function possibly calling a loop, please? Thanks, Erin On Thu, Oct 13, 2022 at 1:49 AM Steven T. Yen <styen at ntu.edu.tw> wrote:> Thanks Erin. > > No. Removing the second line (so that cat simply prints something else), > > cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit > Probabilities") > # "\n\nlogistic =",logistic) > > I get yet another nonsense: > > Error in cat("\nMarginal and Discrete Effects of Gen Ordered Logit / > Probit Probabilities") : > argument "j" is missing, with no default > > > On 10/13/2022 3:37 PM, Erin Hodgess wrote: > > Hi Steven: > > Do you have a variable called logistic, please? I think that might be the > culprit. > > Thanks, > Erin > > On Thu, Oct 13, 2022 at 1:35 AM Steven T. Yen <styen at 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 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. >> > -- > Erin Hodgess, PhD > mailto: erinm.hodgess at gmail.com > > --Erin Hodgess, PhD mailto: erinm.hodgess at gmail.com [[alternative HTML version deleted]]
Hi Steven, I think Erin is right, unless there is a variable named "logistic" visible within the function, "cat" will think it is either an argument or an R object. If you have the "psych" package loaded, it may see it as a closure. There is also a "Logistic" in the stats package, but that shouldn't be visible due to the capital L Jim On Thu, Oct 13, 2022 at 6:55 PM Steven T. Yen <styen at ntu.edu.tw> wrote:> > Thanks Erin. > > No. Removing the second line (so that cat simply prints something else), > > cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit > Probabilities") > # "\n\nlogistic =",logistic) > > I get yet another nonsense: > > Error in cat("\nMarginal and Discrete Effects of Gen Ordered Logit / > Probit Probabilities") : > argument "j" is missing, with no default > > > > On 10/13/2022 3:37 PM, Erin Hodgess wrote: > > Hi Steven: > > > > Do you have a variable called logistic, please? I think that might be > > the culprit. > > > > Thanks, > > Erin > > > > On Thu, Oct 13, 2022 at 1:35 AM Steven T. Yen <styen at 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 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 > > <http://www.R-project.org/posting-guide.html> > > and provide commented, minimal, self-contained, reproducible code. > > > > -- > > Erin Hodgess, PhD > > mailto: erinm.hodgess at gmail.com > [[alternative HTML version deleted]] > > ______________________________________________ > 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.
? Thu, 13 Oct 2022 15:49:57 +0800 "Steven T. Yen" <styen at ntu.edu.tw> ?????:> No. Removing the second line (so that cat simply prints something > else), > > cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit > Probabilities") > #??? "\n\nlogistic =",logistic) > > I get yet another nonsense: > > Error in cat("\nMarginal and Discrete Effects of Gen Ordered Logit / > Probit Probabilities") : > ? argument "j" is missing, with no defaultI don't see any problems with quoting or parentheses in the parts of the code you're showing us, but they may be present elsewhere. If you step the function in debugger (see ?debugonce and ?browser), does it crash in the call to cat()? If you take your function apart by applying as.list(body(fun)) (and furthermore applying as.list() to any parts of the function), do you see the call to cat() taking exactly the arguments you mean it to take? -- Best regards, Ivan