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
########################################################################
#####################################
|