Skip to content

Instantly share code, notes, and snippets.

@daroczig
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daroczig/480af8ad766e96dd25f4 to your computer and use it in GitHub Desktop.
Save daroczig/480af8ad766e96dd25f4 to your computer and use it in GitHub Desktop.
evals demo
library(pander)
evals(readLines('demo.R'))
1+1
stop('foo')
I love R
chisq.test(table(mtcars$am, mtcars$gear))
> library(pander)
> evals(readLines('demo.R'))
[[1]]
$src
[1] "1+1"
$result
[1] 2
$output
[1] "[1] 2"
$type
[1] "numeric"
$msg
$msg$messages
NULL
$msg$warnings
NULL
$msg$errors
NULL
$stdout
NULL
attr(,"class")
[1] "evals"
[[2]]
$src
[1] "stop('foo')"
$result
NULL
$output
NULL
$type
[1] "error"
$msg
$msg$messages
NULL
$msg$warnings
NULL
$msg$errors
[1] "foo"
$stdout
NULL
attr(,"class")
[1] "evals"
[[3]]
$src
[1] "I love R"
$result
NULL
$output
NULL
$type
[1] "error"
$msg
$msg$messages
NULL
$msg$warnings
NULL
$msg$errors
[1] "Unexpected symbol at character 3 in line 1: ` I love`"
$stdout
NULL
attr(,"class")
[1] "evals"
[[4]]
$src
[1] "chisq.test(table(mtcars$am, mtcars$gear))"
$result
Pearson's Chi-squared test
data: table(mtcars$am, mtcars$gear)
X-squared = 20.9447, df = 2, p-value = 2.831e-05
$output
[1] ""
[2] "\tPearson's Chi-squared test"
[3] ""
[4] "data: table(mtcars$am, mtcars$gear)"
[5] "X-squared = 20.9447, df = 2, p-value = 2.831e-05"
[6] ""
$type
[1] "htest"
$msg
$msg$messages
NULL
$msg$warnings
[1] "Chi-squared approximation may be incorrect"
$msg$errors
NULL
$stdout
NULL
attr(,"class")
[1] "evals"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment