s-news
[Top] [All Lists]

Re: Code that works outside a custom function but not inside

To: sbmailinglist@gmail.com
Subject: Re: Code that works outside a custom function but not inside
From: Terry Therneau <therneau@mayo.edu>
Date: Fri, 31 Oct 2008 08:07:27 -0500 (CDT)
Cc: s-news@lists.biostat.wustl.edu
Reply-to: Terry Therneau <therneau@mayo.edu>
Your problem is the mixed-mode model statement

        histogram (~mydata[,1]|mydata[,2],
                      data = mydata,
                      ....
                      
You want to either
        leave out the "data=mydata" phrase
or use
        histogram(~ X|SD,
                   data=mydata,
                  

  Your first statement says "look in the 'mydata' frame for variable names",
but the mydata data frame does not have 'mydata[,1]' as one of its variable 
names.  You can get away with this at the top level, where Splus can usually 
find things even when given bad directions; but not inside a function.

        Terry T.
                                             


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