| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/evals.R |
| 3 |
\name{eval.msgs} |
| 4 |
\alias{eval.msgs} |
| 5 |
\title{Evaluate with messages} |
| 6 |
\usage{ |
| 7 |
eval.msgs( |
| 8 |
src, |
| 9 |
env = NULL, |
| 10 |
showInvisible = FALSE, |
| 11 |
graph.unify = evalsOptions("graph.unify") |
| 12 |
) |
| 13 |
} |
| 14 |
\arguments{ |
| 15 |
\item{src}{character values containing R code} |
| 16 |
|
| 17 |
\item{env}{environment where evaluation takes place. If not set (by default), a new temporary environment is created.} |
| 18 |
|
| 19 |
\item{showInvisible}{return \code{invisible} results?} |
| 20 |
|
| 21 |
\item{graph.unify}{should \code{eval.msgs} try to unify the style of (\code{lattice} and \code{ggplot2}) plots? If set to \code{TRUE} (by default), some \code{panderOptions()} would apply. Please note that this argument has no effect on \code{base} plots, use \code{evals} instead.} |
| 22 |
} |
| 23 |
\value{ |
| 24 |
a list of parsed elements each containing: \code{src} (the command run), \code{result} (R object: \code{NULL} if nothing returned), \code{print}ed \code{output}, \code{type} (class of returned object if any), informative/wawrning and error messages (if any returned by the command run, otherwise set to \code{NULL}) and possible \code{stdout}t value. See Details above. |
| 25 |
} |
| 26 |
\description{ |
| 27 |
This function takes text(s) of R code and \code{eval}s all at one run - returning a list with four elements. See \code{Details}. |
| 28 |
} |
| 29 |
\details{ |
| 30 |
\code{eval.msgs} returns a detailed list of the result of evaluation: |
| 31 |
\itemize{ |
| 32 |
\item \emph{src} - character vector of specified R code. |
| 33 |
\item \emph{result} - result of evaluation. \code{NULL} if nothing is returned. If any R code returned an R object while evaluating then the \emph{last} R object will be returned as a raw R object. If a graph is plotted in the end of the given R code (remember: \emph{last} R object), it would be automatically printed (see e.g. \code{lattice} and \code{ggplot2}). |
| 34 |
\item \emph{output} - character vector of printed version (\code{capture.output}) of \code{result} |
| 35 |
\item \emph{type} - class of generated output. 'NULL' if nothing is returned, 'error' if some error occurred. |
| 36 |
\item \emph{msg} - possible messages grabbed while evaluating specified R code with the following structure: |
| 37 |
\itemize{ |
| 38 |
\item \emph{messages} - character vector of possible diagnostic message(s) |
| 39 |
\item \emph{warnings} - character vector of possible warning message(s) |
| 40 |
\item \emph{errors} - character vector of possible error message(s) |
| 41 |
} |
| 42 |
\item \emph{stdout} - character vector of possibly printed texts to standard output (console) |
| 43 |
} |
| 44 |
} |
| 45 |
\examples{ |
| 46 |
\dontrun{ |
| 47 |
eval.msgs('1:5') |
| 48 |
eval.msgs('x <- 1:5') |
| 49 |
eval.msgs('lm(mtcars$hp ~ mtcars$wt)') |
| 50 |
|
| 51 |
## plots |
| 52 |
eval.msgs('plot(runif(100))') |
| 53 |
eval.msgs('histogram(runif(100))') |
| 54 |
|
| 55 |
## error handling |
| 56 |
eval.msgs('runiff(23)') |
| 57 |
eval.msgs('runif is a nice function') |
| 58 |
eval.msgs('no.R.object.like.that') |
| 59 |
|
| 60 |
## messages |
| 61 |
eval.msgs(c('message("FOO")', '1:2')) |
| 62 |
eval.msgs(c('warning("FOO")', '1:2')) |
| 63 |
eval.msgs(c('message("FOO");message("FOO");warning("FOO")', '1:2')) |
| 64 |
eval.msgs('warning("d");warning("f");1') |
| 65 |
|
| 66 |
## stdout |
| 67 |
eval.msgs('cat("writing to console")') |
| 68 |
eval.msgs('cat("writing to console");1:4') |
| 69 |
} |
| 70 |
} |
| 71 |
\seealso{ |
| 72 |
\code{\link{evals}} |
| 73 |
} |