[S] calling manova from within a function...scope problem?

Suzanne Cashman (scashman@empnet.com)
Mon, 29 Jun 1998 23:58:38 -0700


Hello, S-users;
I am trying to call manova() from within a function & believe I am running
into some sort of variable definition problem or scope problem - which
seems to be somewhat unique to manova. My function creates local objects
which are the arguments for the manova call. However, manova() can not see
these objects within the local frame. Other functions, such as aov() &
plot() have no problem. How do I force manova to evaluate the current
frame arguments? See function:

manova.test( c(10.0, 130.0, 9.0, 260.0, 14.0, 140.0, 1.0, 200.0, 1.5,
180.0, 1.0, 125.0, 2.0, 210.0), c(1,1,1,2,2,2,2) )

> manova.test <- function(y, x)
{
print("y =")
print(y)
print("x=")
print(x)
n <- length(x)
a <- t(matrix(y, ncol = n))
print("a")
print(a)
fit <- aov(x ~ a)
fit2 <- manova(a ~ x)
}
> manova.test(c(10, 130, 9, 260, 14, 140, 1, 200, 1.5, 180, 1, 125, 2,
210), c(1, 1, 1, 2, 2, 2, 2))
[1] "y ="
[1] 10.0 130.0 9.0 260.0 14.0 140.0 1.0 200.0 1.5 180.0 1.0 1
25.0 2.0 210.0
[1] "x="
[1] 1 1 1 2 2 2 2
[1] "a"
[,1] [,2]
[1,] 10.0 130
[2,] 9.0 260
[3,] 14.0 140
[4,] 1.0 200
[5,] 1.5 180
[6,] 1.0 125
[7,] 2.0 210
Error in manova(a ~ x): Object "a" not found
Dumped

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