RE: [R] Logic regression equation in character form?

2005-02-24 Thread Glynn, Earl
> -Original Message-
> From: Thomas Lumley [mailto:[EMAIL PROTECTED] 
> You want capture.output().

Thank you!  This is exactly what I needed.

efg

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Logic regression equation in character form?

2005-02-24 Thread Thomas Lumley
On Thu, 24 Feb 2005, Earl F. Glynn wrote:
Why does this NOT work?
typeof(logicfit)
[1] "list"
class(logicfit)
[1] "logreg"
x <- paste(print(logicfit))
score 0.968
+2.14 * (((not X4) or ((not X13) and X19)) and (not X3)) -1.25 * not
X1) or (not X3)) and ((not X2) or X20)) and (((not X17) and X16) or ((not
X20) and (not X1
x
character(0)

It doesn't work because print() doesn't return the same thing that it 
prints. You need the output, not the return value.
You want capture.output().

-thomas
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Logic regression equation in character form?

2005-02-24 Thread Earl F. Glynn
Perhaps I can ask a more focused question:

"Earl F. Glynn" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I want to get some "simple" logic regression examples to work before
> exploring a hard problem.
..
> logicfit <- logreg(resp=Y, bin=X,
>type = REGRESSION.TYPE<-2,
>select = FIT.SINGLE.MODEL<-1,
>ntrees=1,
>nleaves=2,   # force shape of final tree
>anneal.control=Annealing)

OK, I have a logic regression equation and just want it in a character form.

For example, I can see this equation from the R command prompt:

> logicfit
score 0.968
 +2.14 * (((not X4) or ((not X13) and X19)) and (not X3)) -1.25 * not
X1) or (not X3)) and ((not X2) or X20)) and (((not X17) and X16) or ((not
X20) and (not X1

But I cannot figure out how to get this equation in character form:

Why does this NOT work?
> typeof(logicfit)
[1] "list"
> class(logicfit)
[1] "logreg"
> x <- paste(print(logicfit))
score 0.968
 +2.14 * (((not X4) or ((not X13) and X19)) and (not X3)) -1.25 * not
X1) or (not X3)) and ((not X2) or X20)) and (((not X17) and X16) or ((not
X20) and (not X1
> x
character(0)
> cat(x, "\n")
 [nothing]
>

The "print" makes the following error go away but does not give me the
string displayed on the R console:
> cat(logicfit)
Error in cat(list(...), file, sep, fill, labels, append) :
argument 1 not yet handled by cat


This simpler analogy DOES work:
> x <- paste( print("string") )
[1] "string"
> x
[1] "string"
> cat(x, "\n")
string
>

Any clues?  Thanks for any help with this.

efg

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html