## Not run:
# #* This example is taken from the discussion of argument checking at
# #* http://www.r-bloggers.com/programming-with-r---checking-function-arguments/
# cylinder.volume <- function(height, radius){
# Check <- newArgCheck()
# if (missing(height)){
# addError("A value for 'height' was not provided",
# Check)
# } else{
# if (height < 0)
# addError("'height' must be a non-negative number",
# Check)
# }
#
# if (missing(height)){
# addError("A value for 'radius' was not provided",
# Check)
# } else {
# if (radius < 0)
# addError("'radius' must be a non-negative number",
# Check)
# }
#
# if (!missing(height) & !missing(radius)){
# if (height < radius)
# addWarning("When 'height' < 'radius', you have a short, awkward looking cylinder",
# Check)
# }
#
# finishArgCheck(Check)
#
# pi * radius^2 * height
# }
#
# cylinder.volume()
# cylinder.volume(height = -3)
# cylinder.volume(height = 3, radius = -2)
# cylinder.volume(height = 3, radius=2)
# cylinder.volume(height = -8, radius = 4)
# ## End(Not run)
Run the code above in your browser using DataLab