# define a script string
script <- "x <- rnorm(100)
y <- x + rnorm(100,0.25)
summary(lm(y~x))"
# evaluate the script string, returning a transcript.
result <- texteval(script, "")
cat(result)
# evaluate the script string, returning the printed output.
result <- printed(script, "")
cat(result)
Run the code above in your browser using DataLab