Re: [R] cat in a subroutine

2022-10-13 Thread Steven T. Yen
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  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@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.
>
[[alternative HTML version deleted]]

__
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.


Re: [R] cat in a subroutine

2022-10-13 Thread Bill Dunlap
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  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@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.
>

[[alternative HTML version deleted]]

__
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.


Re: [R] cat in a subroutine

2022-10-13 Thread Ivan Krylov
В Thu, 13 Oct 2022 15:49:57 +0800
"Steven T. Yen"  пишет:

> 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

I 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

__
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.


Re: [R] cat in a subroutine

2022-10-13 Thread Steven Yen
No. I just run the subroutine containing those line, with result going to 
destination go probit1.r.me.it and printed it.

Steven from iPhone

> On Oct 13, 2022, at 5:09 PM, Jim Lemon  wrote:
> 
> Have you assigned the valuie of goprobit1.r.me.kr to "fortytwo", or
> indeed anything?
> 
> Jim
> 
>> On Thu, Oct 13, 2022 at 8:02 PM Steven T. Yen  wrote:
>> 
>> Not really.
>> 
>> fortytwo<-42
>> cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
>> Probabilities",
>> "logisitic =",fortytwo,"\n")
>> 
>>> goprobit1.r.me.kr<-me.gologit.r(goprobit1,embellished=TRUE,
>> + resampling=TRUE,ndraws=5);
>> goprobit1.r.me.kr
>> Error in cat("\nMarginal and Discrete Effects of Gen Ordered Logit /
>> Probit Probabilities",  :
>>   unused arguments (fortytwo, "\n")
>> 
>>> On 10/13/2022 4:46 PM, Jim Lemon wrote:
>>> Hi Steven & Erin,
>>> This works:
>>> 
>>> fortytwo<-42
>>> cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
>>> Probabilities","logisitic =",fortytwo,"\n")
>>> j<-grep(".one\\b",c(".one\\a",".one\\b"))
>>> 
>>> Marginal and Discrete Effects of Gen Ordered Logit / Probit
>>> Probabilities logisitic = 42
>>> 
>>> If I don't define fortytwo before calling cat, it doesn't.
>>> So we know what the answer is.
>>> 
>>> Jim
>>> 
>>> On Thu, Oct 13, 2022 at 7:36 PM Steven Yen  wrote:
 t<-abs(me)/se; p<-2*(1-pt(t,nrow(x)))

[[alternative HTML version deleted]]

__
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.


Re: [R] cat in a subroutine

2022-10-13 Thread Jim Lemon
Have you assigned the valuie of goprobit1.r.me.kr to "fortytwo", or
indeed anything?

Jim

On Thu, Oct 13, 2022 at 8:02 PM Steven T. Yen  wrote:
>
> Not really.
>
> fortytwo<-42
> cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
> Probabilities",
>  "logisitic =",fortytwo,"\n")
>
>  > goprobit1.r.me.kr<-me.gologit.r(goprobit1,embellished=TRUE,
> + resampling=TRUE,ndraws=5);
> goprobit1.r.me.kr
> Error in cat("\nMarginal and Discrete Effects of Gen Ordered Logit /
> Probit Probabilities",  :
>unused arguments (fortytwo, "\n")
>
> On 10/13/2022 4:46 PM, Jim Lemon wrote:
> > Hi Steven & Erin,
> > This works:
> >
> > fortytwo<-42
> > cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
> > Probabilities","logisitic =",fortytwo,"\n")
> > j<-grep(".one\\b",c(".one\\a",".one\\b"))
> >
> > Marginal and Discrete Effects of Gen Ordered Logit / Probit
> > Probabilities logisitic = 42
> >
> > If I don't define fortytwo before calling cat, it doesn't.
> > So we know what the answer is.
> >
> > Jim
> >
> > On Thu, Oct 13, 2022 at 7:36 PM Steven Yen  wrote:
> >> 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)
> >> }
> >>
> >> Steven from iPhone
> >>
> >>> On Oct 13, 2022, at 3:37 PM, Erin Hodgess  wrote:
> >>>
> >>> 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)
> >>> }
> >>  [[alternative HTML version deleted]]
> >>
> >> __
> >> 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.


Re: [R] cat in a subroutine

2022-10-13 Thread Steven T. Yen

Not really.

fortytwo<-42
cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit 
Probabilities",

    "logisitic =",fortytwo,"\n")

> goprobit1.r.me.kr<-me.gologit.r(goprobit1,embellished=TRUE,
+ resampling=TRUE,ndraws=5); 
goprobit1.r.me.kr
Error in cat("\nMarginal and Discrete Effects of Gen Ordered Logit / 
Probit Probabilities",  :

  unused arguments (fortytwo, "\n")

On 10/13/2022 4:46 PM, Jim Lemon wrote:

Hi Steven & Erin,
This works:

fortytwo<-42
cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
Probabilities","logisitic =",fortytwo,"\n")
j<-grep(".one\\b",c(".one\\a",".one\\b"))

Marginal and Discrete Effects of Gen Ordered Logit / Probit
Probabilities logisitic = 42

If I don't define fortytwo before calling cat, it doesn't.
So we know what the answer is.

Jim

On Thu, Oct 13, 2022 at 7:36 PM Steven Yen  wrote:

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)
}

Steven from iPhone


On Oct 13, 2022, at 3:37 PM, Erin Hodgess  wrote:

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)
}

 [[alternative HTML version deleted]]

__
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.


Re: [R] cat in a subroutine

2022-10-13 Thread Jim Lemon
Hi Steven & Erin,
This works:

fortytwo<-42
cat("\nMarginal and Discrete Effects of Gen Ordered Logit / Probit
Probabilities","logisitic =",fortytwo,"\n")
j<-grep(".one\\b",c(".one\\a",".one\\b"))

Marginal and Discrete Effects of Gen Ordered Logit / Probit
Probabilities logisitic = 42

If I don't define fortytwo before calling cat, it doesn't.
So we know what the answer is.

Jim

On Thu, Oct 13, 2022 at 7:36 PM Steven Yen  wrote:
>
> 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)
> }
>
> Steven from iPhone
>
> > On Oct 13, 2022, at 3:37 PM, Erin Hodgess  wrote:
> >
> > 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)
> > }
>
> [[alternative HTML version deleted]]
>
> __
> 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.


Re: [R] cat in a subroutine

2022-10-13 Thread Steven Yen
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)
}

Steven from iPhone

> On Oct 13, 2022, at 3:37 PM, Erin Hodgess  wrote:
> 
> 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)
> }

[[alternative HTML version deleted]]

__
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.


Re: [R] cat in a subroutine

2022-10-13 Thread Erin Hodgess
Steven, would you mind putting that section of code in again, with the cat
statement, please?

I have an idea...
Erin Hodgess, PhD
mailto: erinm.hodg...@gmail.com


On Thu, Oct 13, 2022 at 2:13 AM Jim Lemon  wrote:

> 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  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 
> 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@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.hodg...@gmail.com
> > [[alternative HTML version deleted]]
> >
> > __
> > 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.
>

[[alternative HTML version deleted]]

__
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.


Re: [R] cat in a subroutine

2022-10-13 Thread Steven Yen
Yes, these lines are part of a subroutine calling yet more procedures. What 
frustrated me was, I am not doing anything different from other routines. My 
cat command in the recent code does not do anything other than printing a line 
of plain text. I am clueless.

Steven from iPhone

> On Oct 13, 2022, at 3:54 PM, Erin Hodgess  wrote:
> 
> 
> 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  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  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@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.hodg...@gmail.com
> -- 
> Erin Hodgess, PhD
> mailto: erinm.hodg...@gmail.com

[[alternative HTML version deleted]]

__
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.


Re: [R] cat in a subroutine

2022-10-13 Thread Jim Lemon
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  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  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@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.hodg...@gmail.com
> [[alternative HTML version deleted]]
>
> __
> 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.


Re: [R] cat in a subroutine

2022-10-13 Thread Steven T. Yen
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  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@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.hodg...@gmail.com
[[alternative HTML version deleted]]

__
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.


Re: [R] cat in a subroutine

2022-10-13 Thread Erin Hodgess
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  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  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@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.hodg...@gmail.com
>
> --
Erin Hodgess, PhD
mailto: erinm.hodg...@gmail.com

[[alternative HTML version deleted]]

__
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.


Re: [R] cat in a subroutine

2022-10-13 Thread Erin Hodgess
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  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@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.hodg...@gmail.com

[[alternative HTML version deleted]]

__
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.