[R] incomplete function output

Spencer Graves spencer.graves at pdf.com
Wed Oct 13 19:28:26 CEST 2004

      Only the last appears, because the function returns only the last, 
which then gets printed.  The answer to your question depends on whether 
you want to see the results or store them.  To see them, try the 

root.print <- function(var)
print(PP.test(var, lshort = TRUE) )
print(PP.test(var, lshort = FALSE) )

#---Augmented Dickey-Fuller 
print(adf.test(var, alternative = "stationary", k =

print(kpss.test(var, null = "Level", lshort = TRUE))
print(kpss.test(var, null = "Trend", lshort = FALSE))

	  To store the results, try:  

root.store <- function(var)
t1 <- PP.test(var, lshort = TRUE) 
t2 <- PP.test(var, lshort = FALSE) 

#---Augmented Dickey-Fuller 
t3 <- adf.test(var, alternative = "stationary", k =

t4 <- kpss.test(var, null = "Level", lshort = TRUE)
t5 <- kpss.test(var, null = "Trend", lshort = FALSE)
list(PP.testT=t1, PP.testF=t2, adf.test=t3, kpss.testT=t4, kpss.testF=t5)

	  hope this helps.  
	  spencer graves

bogdan romocea wrote:

>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,
>root <- function(var)
>PP.test(var, lshort = TRUE) 
>PP.test(var, lshort = FALSE) 
>#---Augmented Dickey-Fuller 
>adf.test(var, alternative = "stationary", k =
>kpss.test(var, null = "Level", lshort = TRUE)
>kpss.test(var, null = "Trend", lshort = FALSE)
>R-help at stat.math.ethz.ch mailing list
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Spencer Graves, PhD, Senior Development Engineer
O:  (408)938-4420;  mobile:  (408)655-4567

More information about the R-help mailing list