countWarnings: Evaluates an Expression and Return the Number of Warnings

Description Usage Arguments Value References Examples

View source: R/miscellaneous.R

Description

Evaluates an expression. Returns a list with the value of expression and the number of warnings thrown by an expression.

Usage

1

Arguments

expr

the expression to evaluate

Value

list of length two. The first element of the list is names "ans" and it contains the results of the expression. The second element of the list is named "warnings" and contains the number of warning generated by the expression.

References

http://stackoverflow.com/questions/4020239/warnings-does-not-work-within-a-function-how-can-one-work-around-this

Examples

1
2
3
4
5
6
7
8
countWarnings(log(-1))
foo <- function(){
   warning("first warning!")
   warning("second warning!")
   warning("third warning!")
   invisible()
 }
 countWarnings(foo())

guytuori/simScores documentation built on May 17, 2019, 9:29 a.m.