s-news
[Top] [All Lists]

Re: [S] modifying text.tree()

To: Don McKenzie <dmck@silvae.cfr.washington.edu>
Subject: Re: [S] modifying text.tree()
From: Christian Keller <ckeller@aicos.com>
Date: Fri, 24 Jul 1998 09:20:12 +0200
Cc: S-news <s-news@wubios.wustl.edu>
Organization: AICOS Technologies AG (http://www.aicos.com)
References: <3.0.5.32.19980723123045.008785f0@silvae.cfr.washington.edu>
Sender: owner-s-news@wubios.wustl.edu
Don McKenzie wrote:

>> I would like to create a modified version of text.tree() to
>> write back-transformed fitted values at the terminal nodes. 
>> ...

Add a new argument BACKTRANS to text.tree()
an insert the following lines before, e.g., 
        cxy <- par("cxy")[2]

### ------------------------------------------------------------
 if(is.null(ylevels)){ # only for regression trees
    if(!missing(BACKTRANS)){
      if(is.character(BACKTRANS))
        BACKTRANS <- get(BACKTRANS, mode = "function")
      else if(mode(BACKTRANS) != "function") {
        farg <- substitute(BACKTRANS)
        if(mode(farg) == "name")
          BACKTRANS <- get(farg, mode = "function")
        else stop(paste("\"", farg, "\" is not a function", sep = ""))
      }
      frame$yval <- BACKTRANS(frame$yval)   # back transformation
    }
  }

### -------------------------------------------------------------

You can add these lines to the function post.tree() as well
(which does not call text.tree). 
But I am not sure whether post.tree() is available in v. 4.5 for
Windows.

-- Christian
----------------------------------------------------------
Christian Keller                Tel:      +41 61 686 98 81
AICOS Technologies AG           Fax:      +41 61 686 98 88
Efringerstrasse 32              email:   ckeller@aicos.com
CH-4057 Basel, Switzerland      Web: http://www.aicos.com/
----------------------------------------------------------
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>