s-news
[Top] [All Lists]

"data =" option

To: <s-news@lists.biostat.wustl.edu>
Subject: "data =" option
From: "Zhan, Ping N." <Ping.Zhan@celera.com>
Date: Thu, 16 Sep 2004 15:59:58 -0400
Thread-index: AcSb8J3Bh4XB7w8hSkWTUsxqvV2CqAANK0fA
Thread-topic: "data =" option
Hi S users,


I have the following simple test code and could someone explain why only
xy.test function ran? I got the same warning message for function
xy.test2 and xy.test3. 
If I want to pass a dataset to a function where "data = " is a required
argument, e.g. lm, how the code should be modified? I am using SPlus
Windows 6.2.

TIA,
Ping

########################################################################
#################################### 

xy.test <-function(namexy)
{
        xy <-get(namexy)
        fit1 <-lm(xy[,1] ~ xy[,2])
}

xy.test2 <-function(namexy)
{
        xy <-get(namexy)
        fit1 <-lm(xy[,1] ~ xy[,2], data = xy)
}

xy.test3 <-function(x1y1)
{
        fit1 <-lm(x1y1[,1] ~ x1y1[,2], data = x1y1)
}

x1 <-rnorm(100)
y1 <-rnorm(100)
x1y1 <-cbind(x1,y1)

xy.test("x1y1")
xy.test2("x1y1")
xy.test3(x1y1)
Warning messages:
  Numerical expression has 200 elements: only the first used in:
model.frame(formula, data, na.action, dots)
Problem in xy.test3(x1y1): Invalid frame number, 0

########################################################################
#####################################


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