[R] Inheritance and automatic function call on script exit

Ralf B ralf.bierig at gmail.com
Wed Oct 6 17:31:27 CEST 2010


Here the modified script with what I learned from  Joshua:

#
# superscript
#

output <- NULL

writeOutput <- function() {
	processTime <- proc.time()
	outputFilename <- paste("C:/myOutput_", processTime[3], ".csv", sep="")
	write.csv(output, file = outputFilename)
}
on.exit(writeOutput, add=T)


#
# subscript
#

source("C:/superscript.R")
output <- data.frame(a=c(1,2,3), b=c(4,5,6))

For some reason, the file is not created. So it seems not to do the
call. What do I do wrong?

Ralf



More information about the R-help mailing list