Article View: aus.stats.s
Article #261Re: [S] Strange error from tree()
From: "Sung, Myong-Hee (NCI)"
Date: Fri, 03 Aug 2001 19:18
Date: Fri, 03 Aug 2001 19:18
53 lines
2921 bytes
2921 bytes
Great thank-you to Bill Dunlap at Insightful for the precise solution to my
problem.
Here are the original question and his message:
> I got a mysterious error from running command tree() inside my script.
The
> relevant
> part of the code is:
>
>
tree(factor(c(rep("P",nP),rep("N",nN)))~.,data=data.frame(rbind(bind,nonbind
> )))
>
> The error message is "Object "nP" not found". But nP is clearly defined
and
> has the
> correct value just before tree() is run as can be seen by cat().
tree looks in the columns of data.frame given as the data= argument,
then in the global data bases for when it needs to look up names
in the formula. If you supply a data= argument it does not look
in the frame of the function calling tree.
One way to do this is
response <- factor(c(rep("P",nP),rep("N",nN)))
data <- data.frame(rbind(bind,nonbind), response) # why rbind?
tree(response~., data=data)
----------------------------------------------------------------------------
Bill Dunlap 22461 Mt Vernon-Big Lake Rd
Insightful Corporation Mount Vernon, WA 98274
bill@insightful.com 360-428-8146
Myong-Hee Sung, Ph.D.
Molecular Statistics and Bioinformatics Section
Biometric Research Branch
Division of Cancer Treatment and Diagnosis
National Cancer Institute
National Institutes of Health
6130 Executive Blvd. EPN Room 8146, MSC 7434
Bethesda, MD 20892-7434
sungm@mail.nih.gov
phone: 301-402-0364
fax: 301-402-0560
---------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
---
Technical Details
Message-ID:
<76D006EB9224D411B12B0008C7C59D960136FCE7@nihexchange9.nih.gov>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!usenet.net.nz!203.97.37.7!203.97.37.7!news.xtra.co.nz!news1.optus.net.au!optus!news.usyd.edu.au!news.nsw.CSIRO.AU!cmis.csiro.au!owner-s-newsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fa931,13fc4f578c49dc91
X-Google-Attributes: gidfa931,public
X-Google-ArrivalTime: 2001-08-03 12:49:47 PST
Newsgroups: aus.stats.s
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!usenet.net.nz!203.97.37.7!203.97.37.7!news.xtra.co.nz!news1.optus.net.au!optus!news.usyd.edu.au!news.nsw.CSIRO.AU!cmis.csiro.au!owner-s-news
From: sungm@mail.nih.gov ("Sung, Myong-Hee (NCI)")
Subject: Re: [S] Strange error from tree()
X-Nntp-Posting-Host: snowy.nsw.cmis.csiro.au
Content-Type: text/plain
Message-ID: <76D006EB9224D411B12B0008C7C59D960136FCE7@nihexchange9.nih.gov>
Sender: majordomo@mailhost.nsw.cmis.CSIRO.AU
Organization: CSIRO Australia
X-To: "'s-news@wubios.wustl.edu'" <s-news@wubios.wustl.edu>
Mime-Version: 1.0
Date: Fri, 3 Aug 2001 19:18:10 GMT
X-Mailer: Internet Mail Service (5.5.2653.19)
Content-Length: 1771
X-Precedence: bulk
X-Received: by ims.hub.nih.gov with Internet Mail Service (5.5.2653.19)
id <QC6DZGQ3>; Fri, 3 Aug 2001 13:22:13 -0400
Lines: 53