fil <- file.path(tempdir(), "foo.R")
cat("x = 1:10\ny = 3*x + 7 + rnorm(length(x))\n", file = fil)
sc = updatingScript(fil)
as(sc, "Script")
con = file(fil, "at")
cat("z = x + y", file = con)
close(con)
as(sc, "Script")
Run the code above in your browser using DataLab