[R] incomplete function output

Austin, Matt maustin at amgen.com
Wed Oct 13 19:28:12 CEST 2004


I would return the values from the various tests in a list. If you only want
them to print and not for use in other parts of your program you could
explicitly print each test using print().

root <- function(var)
{
#---Phillips-Perron
 test1 <- PP.test(var, lshort = TRUE) 
 test2 <- PP.test(var, lshort = FALSE) 

#---Augmented Dickey-Fuller 
 test3 <- adf.test(var, alternative = "stationary", k =
 test4 <- trunc((length(var)-1)^(1/3)))

#---KPSS
 test5 <- kpss.test(var, null = "Level", lshort = TRUE)
 test6 <- kpss.test(var, null = "Trend", lshort = FALSE)
 list(test1, test2, test3, test4, test5, test6)
}

--Matt
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of bogdan romocea
Sent: Wednesday, October 13, 2004 10:20 AM
To: r-help at stat.math.ethz.ch
Subject: [R] incomplete function output


Dear R users,

I have a function (below) which encompasses several tests.
However, when I run it, only the output of the last test is
displayed. How can I ensure that the function root(var)
will run and display the output from all tests, and not
just the last one?

Thank you,
b.

root <- function(var)
{
#---Phillips-Perron
PP.test(var, lshort = TRUE) 
PP.test(var, lshort = FALSE) 

#---Augmented Dickey-Fuller 
adf.test(var, alternative = "stationary", k =
trunc((length(var)-1)^(1/3)))

#---KPSS
kpss.test(var, null = "Level", lshort = TRUE)
kpss.test(var, null = "Trend", lshort = FALSE)
}

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html




More information about the R-help mailing list