Learn R Programming

rapport (version 0.31)

eval.msgs: Evaluate with messages

Description

This function takes text(s) of R code and evals all at one run then returns a list with four elements:

Usage

eval.msgs(src, env = NULL)

Arguments

src
character values containing R code
env
environment where evaluation takes place. If not set (by default), a new temporary environment is created.

Value

  • a list of parsed elements each containing: src (the command run), output (what the command returns, NULL if nothing returned, path to image file if a plot was generated), type (class of returned object if any) and messages: warnings (if any returned by the command run, otherwise set to NULL) and errors (if any returned by the command run, otherwise set to NULL). See Details above.

Details

  • src- a character value with specified R code.
  • output- generated output.NULLif nothing is returned. If any string returned an R object while evaluating then thelastR object will be returned as a raw R object. If a graph is plotted in the given text, the returned object is a string specifying the path to the saved png in temporary directory (see:tempfile). If multiple plots was run in the same run (see: nested lists as inputs above) then the last plot is saved. If graphic device was touched, then no other R objects will be returned.
  • type- class of generated output. "NULL" if nothing is returned, "image" if the graphic device was touched, "error" if some error occurred.
  • msg- possible messages grabbed while evaluating specified R code with the following structure:
    • messages- string of possible diagnostic message(s)
    • warnings- string of possible warning message(s)
    • errors- string of possible error message(s)

See Also

evals

Examples

Run this code
eval.msgs('1:5')
eval.msgs(c('1:3', 'runiff(23)'))
eval.msgs(c('1:5', '3:5'))
eval.msgs(c('pi', '1:10', 'NULL'))
eval.msgs('pi')
eval.msgs('1:2')
identical(evals('pi')[[1]], eval.msgs('pi'))

Run the code above in your browser using DataLab