eval.msgs: Evaluate with messages

Description Usage Arguments Details Value See Also Examples

View source: R/evals.R

Description

This function takes text(s) of R code and evals all at one run - returning a list with four elements. See Details.

Usage

1
2
eval.msgs(src, env = NULL, showInvisible = FALSE,
  graph.unify = evalsOptions("graph.unify"))

Arguments

src

character values containing R code

env

environment where evaluation takes place. If not set (by default), a new temporary environment is created.

showInvisible

return invisible results?

graph.unify

should eval.msgs try to unify the style of (lattice and ggplot2) plots? If set to TRUE (by default), some panderOptions() would apply. Please note that this argument has no effect on base plots, use evals instead.

Details

eval.msgs returns a detailed list of the result of evaluation:

Value

a list of parsed elements each containing: src (the command run), result (R object: NULL if nothing returned), printed output, type (class of returned object if any), informative/wawrning and error messages (if any returned by the command run, otherwise set to NULL) and possible stdoutt value. See Details above.

See Also

evals

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 
eval.msgs('1:5')
eval.msgs('x <- 1:5')
eval.msgs('lm(mtcars$hp ~ mtcars$wt)')

## plots
eval.msgs('plot(runif(100))')
eval.msgs('histogram(runif(100))')

## error handling
eval.msgs('runiff(23)')
eval.msgs('runif is a nice function')
eval.msgs('no.R.object.like.that')

## messages
eval.msgs(c('message("FOO")', '1:2'))
eval.msgs(c('warning("FOO")', '1:2'))
eval.msgs(c('message("FOO");message("FOO");warning("FOO")', '1:2'))
eval.msgs('warning("d");warning("f");1')

## stdout
eval.msgs('cat("writing to console")')
eval.msgs('cat("writing to console");1:4')

## End(Not run)

huashan/pander documentation built on May 16, 2017, 11:59 p.m.