The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Title: Control How Many Times Conditions are Thrown
Description: Provides ability to control how many times in function calls conditions are thrown (shown to the user). Includes control of warnings and messages.
Version: 0.1.0
License: MIT + file LICENSE
URL: https://github.com/ropenscilabs/conditionz
BugReports: http://github.com/ropenscilabs/conditionz/issues
Encoding: UTF-8
Depends: R(≥ 3.2.1)
Imports: R6, uuid
Suggests: testthat
RoxygenNote: 6.1.1
X-schema.org-applicationCategory: Utilities
X-schema.org-keywords: condition, condition-control, warning, message
X-schema.org-isPartOf: https://ropensci.org
NeedsCompilation: no
Packaged: 2019-04-11 16:31:35 UTC; sckott
Author: Scott Chamberlain ORCID iD [aut, cre]
Maintainer: Scott Chamberlain <myrmecocystus@gmail.com>
Repository: CRAN
Date/Publication: 2019-04-24 12:20:07 UTC

condition control

Description

condition control

Author(s)

Scott Chamberlain myrmecocystus@gmail.com


ConditionKeeper

Description

ConditionKeeper

Arguments

times

(integer) number of times to throw condition. required. default: 1

condition

(character) which condition, one of "message" (default) or "warning"

Details

Methods

See Also

handle_conditions()

Examples

x <- ConditionKeeper$new(times = 4)
x
x$get_id()
x$add("one")
x$add("two")
x
x$thrown_already("one")
x$thrown_already("bears")
x$not_thrown_yet("bears")

x$add("two")
x$add("two")
x$add("two")
x$thrown_times("two")
x$thrown_enough("two")
x$thrown_enough("one")

foo <- function(x) {
  message("you gave: ", x)
  return(x)
}
foo('a')
x$handle_conditions(foo('a'))

x <- ConditionKeeper$new(times = 4, condition = "warning")
x
x$add("one")
x$add("two")
x

capture condition

Description

capture condition

Usage

capture_message(expr)

capture_warning(expr)

Examples

foom <- function(x) {
  message("its too bad")
  return(x)
}
capture_message(foom(4))

foow <- function(x) {
  warning("its too bad")
  return(x)
}
capture_warning(foow(4))

Handle conditions

Description

Handle conditions

Usage

handle_conditions(expr, condition = "message", times = 1)

handle_messages(expr, times = 1)

handle_warnings(expr, times = 1)

Arguments

expr

an expression

condition

(character) one of "message" or "warning"

times

(integer) max. times a condition should be thrown. default: 1

Details

Uses ConditionKeeper internally

Value

whatever the expr returns

Examples

foo <- function(x) {
  message("you gave: ", x)
  return(x)
}

foo('a')
capture_message(foo('a'))
handle_conditions(foo('a'))
suppressMessages(handle_conditions(foo('a')))
handle_conditions(foo('a'), "message")

bar <- function(x) {
  for (i in x) message("you gave: ", i)
  return(x)
}
bar(1:5)
handle_conditions(bar(1:5))

handle_messages(foo('a'))

hello <- function(x) {
  warning("you gave: ", x)
  return(x)
}
handle_warnings(hello('a'))

# code block
handle_warnings({
  as.numeric(letters[1:3])
  as.numeric(letters[4:6])
  as.numeric(letters[7:9])
})

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.