Skip to content

Commit

Permalink
improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mllg committed May 13, 2015
1 parent baa3ea6 commit 2e8e854
Show file tree
Hide file tree
Showing 24 changed files with 91 additions and 16 deletions.
1 change: 1 addition & 0 deletions R/anyInfinite.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' Check if an object contains infinte values
#'
#' @description
#' Supported are atomic types (see \code{\link[base]{is.atomic}}), lists and data frames.
#'
#' @param x [\code{ANY}]\cr
Expand Down
1 change: 1 addition & 0 deletions R/anyMissing.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' Check if an object contains missing values
#'
#' @description
#' Supported are atomic types (see \code{\link[base]{is.atomic}}), lists and data frames.
#' Missingness is defined as \code{NA} or \code{NaN} for atomic types and data frame columns,
#' \code{NULL} is defined as missing for lists.
Expand Down
1 change: 1 addition & 0 deletions R/asInteger.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' Convert an argument to an integer
#'
#' @description
#' \code{asInteger} is intended to be used for vectors while \code{asInt} is
#' a specialization for scalar integers and \code{asCount} for scalar
#' non-negative integers.
Expand Down
7 changes: 7 additions & 0 deletions R/assert.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#' Combine multiple checks into one assertion
#'
#' @description
#' You can call this function with an arbitrary number of of \code{check*}
#' functions. The resulting assertion is successful, if at least one
#' check evaluates to \code{TRUE}. Otherwise, \code{assert} throws an
#' informative error messages where the messages from all \code{check*}
#' functions are collected.
#'
#' @param ... [any]\cr
#' List of calls to check functions.
#' @param .var.name [character(1)]\cr
Expand Down
2 changes: 1 addition & 1 deletion R/backports.r
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (getRversion() < "3.2") {
if (getRversion() < "3.2.0") {
dir.exists = function(paths) {
x = file.info(paths)$isdir
!is.na(x) & x
Expand Down
5 changes: 5 additions & 0 deletions R/checkAtomic.r
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#' Check that an argument is an atomic vector
#'
#' @description
#' For the definition of \dQuote{atomic}, see \code{\link[base]{is.atomic}}.
#'
#' @templateVar fn Atmoic
#' @template x
#' @inheritParams checkVector
#' @template checker
#' @family basetypes
#' @useDynLib checkmate c_check_atomic
#' @export
#' @family basetypes
#' @family atomicvector
#' @examples
#' testAtomic(letters, min.len = 1L, any.missing = FALSE)
checkAtomic = function(x, any.missing = TRUE, all.missing = TRUE, len = NULL, min.len = NULL, max.len = NULL, unique = FALSE, names = NULL) {
Expand Down
2 changes: 2 additions & 0 deletions R/checkAtomicVector.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' Check that an argument is an atomic vector
#'
#' @description
#' An atomic vector is defined slightly different from specifications in
#' \code{\link[base]{is.atomic}} and \code{\link[base]{is.vector}}:
#' An atomic vector is either \code{logical}, \code{integer}, \code{numeric},
Expand All @@ -26,6 +27,7 @@
#' Default is \dQuote{any} which performs no check at all.
#' @template checker
#' @family basetypes
#' @family atomicvector
#' @useDynLib checkmate c_check_atomic_vector
#' @export
#' @examples
Expand Down
3 changes: 2 additions & 1 deletion R/checkCount.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Check if an argument is a count
#'
#' A count is a non-negative integerish value.
#' @description
#' A count is defined as non-negative integerish value.
#'
#' @templateVar fn Count
#' @template x
Expand Down
3 changes: 2 additions & 1 deletion R/checkFlag.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Check if an argument is a flag
#'
#' A flag a a single logical value.
#' @description
#' A flag is defined as single logical value.
#'
#' @templateVar fn Flag
#' @template x
Expand Down
3 changes: 2 additions & 1 deletion R/checkNames.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Check names to comply to specific rules
#'
#' Similar to \code{\link{checkNamed}} but you can specify the names directly.
#' @description
#' Similar to \code{\link{checkNamed}} but you can pass the names directly.
#'
#' @templateVar fn Named
#' @param x [\code{character} || \code{NULL}]\cr
Expand Down
3 changes: 1 addition & 2 deletions R/checkPathForOutput.r
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#' \item{Does no file under path \code{x} exist?}
#' \item{Is \code{dirname(x)} writeable?}
#' }
#'
#' A string without slashes is interpreted as a file in the current working directory.
#' Paths are relative to the current working directory.
#'
#' @templateVar fn PathForOutput
#' @template x
Expand Down
3 changes: 3 additions & 0 deletions R/checkPercentage.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#' Check if an argument is a percentage
#'
#' @description
#' This checks \code{x} to be numeric and in the range \code{[0,1]}.
#'
#' @templateVar fn Percentage
#' @template x
#' @template na-handling
Expand Down
3 changes: 2 additions & 1 deletion R/checkString.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Check if an argument is a string
#'
#' A string a scalar character vector.
#' @description
#' A string is defined as a scalar character vector.
#'
#' @templateVar fn String
#' @template x
Expand Down
1 change: 1 addition & 0 deletions R/checkVector.r
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#' Default is \dQuote{any} which performs no check at all.
#' @template checker
#' @family basetypes
#' @family atomicvector
#' @useDynLib checkmate c_check_vector
#' @export
#' @examples
Expand Down
6 changes: 5 additions & 1 deletion man/assert.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ Throws an error if all checks fails and invisibly returns
\code{TRUE} otherwise.
}
\description{
Combine multiple checks into one assertion
You can call this function with an arbitrary number of of \code{check*}
functions. The resulting assertion is successful, if at least one
check evaluates to \code{TRUE}. Otherwise, \code{assert} throws an
informative error messages where the messages from all \code{check*}
functions are collected.
}
\examples{
x = 1:10
Expand Down
39 changes: 38 additions & 1 deletion man/checkAtomic.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,49 @@ Depending on the function prefix:
a string with the error message.
}
\description{
Check that an argument is an atomic vector
For the definition of \dQuote{atomic}, see \code{\link[base]{is.atomic}}.
}
\examples{
testAtomic(letters, min.len = 1L, any.missing = FALSE)
}
\seealso{
Other atomicvector: \code{\link{assertAtomicVector}},
\code{\link{checkAtomicVector}},
\code{\link{testAtomicVector}};
\code{\link{assertVector}}, \code{\link{checkVector}},
\code{\link{testVector}}

Other basetypes: \code{\link{assertArray}},
\code{\link{checkArray}}, \code{\link{testArray}};
\code{\link{assertAtomicVector}},
\code{\link{checkAtomicVector}},
\code{\link{testAtomicVector}};
\code{\link{assertCharacter}},
\code{\link{checkCharacter}},
\code{\link{testCharacter}}; \code{\link{assertComplex}},
\code{\link{checkComplex}}, \code{\link{testComplex}};
\code{\link{assertDataFrame}},
\code{\link{checkDataFrame}},
\code{\link{testDataFrame}};
\code{\link{assertEnvironment}},
\code{\link{checkEnvironment}},
\code{\link{testEnvironment}};
\code{\link{assertFactor}}, \code{\link{checkFactor}},
\code{\link{testFactor}}; \code{\link{assertFunction}},
\code{\link{checkFunction}}, \code{\link{testFunction}};
\code{\link{assertIntegerish}},
\code{\link{checkIntegerish}},
\code{\link{testIntegerish}};
\code{\link{assertInteger}}, \code{\link{checkInteger}},
\code{\link{testInteger}}; \code{\link{assertList}},
\code{\link{checkList}}, \code{\link{testList}};
\code{\link{assertLogical}}, \code{\link{checkLogical}},
\code{\link{testLogical}}; \code{\link{assertMatrix}},
\code{\link{checkMatrix}}, \code{\link{testMatrix}};
\code{\link{assertNumeric}}, \code{\link{checkNumeric}},
\code{\link{testNumeric}}; \code{\link{assertVector}},
\code{\link{checkVector}}, \code{\link{testVector}}

Other basetypes: \code{\link{assertArray}},
\code{\link{checkArray}}, \code{\link{testArray}};
\code{\link{assertAtomicVector}},
Expand Down
5 changes: 5 additions & 0 deletions man/checkAtomicVector.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ In short, this is equivalent to \code{is.atomic(x) && !is.null(x)}.
testAtomicVector(letters, min.len = 1L, any.missing = FALSE)
}
\seealso{
Other atomicvector: \code{\link{assertAtomic}},
\code{\link{checkAtomic}}, \code{\link{testAtomic}};
\code{\link{assertVector}}, \code{\link{checkVector}},
\code{\link{testVector}}

Other basetypes: \code{\link{assertArray}},
\code{\link{checkArray}}, \code{\link{testArray}};
\code{\link{assertAtomic}}, \code{\link{checkAtomic}},
Expand Down
2 changes: 1 addition & 1 deletion man/checkCount.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Depending on the function prefix:
a string with the error message.
}
\description{
A count is a non-negative integerish value.
A count is defined as non-negative integerish value.
}
\details{
This function does not distinguish between
Expand Down
2 changes: 1 addition & 1 deletion man/checkFlag.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Depending on the function prefix:
a string with the error message.
}
\description{
A flag a a single logical value.
A flag is defined as single logical value.
}
\details{
This function does not distinguish between
Expand Down
2 changes: 1 addition & 1 deletion man/checkNames.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Depending on the function prefix:
a string with the error message.
}
\description{
Similar to \code{\link{checkNamed}} but you can specify the names directly.
Similar to \code{\link{checkNamed}} but you can pass the names directly.
}
\examples{
x = 1:3
Expand Down
3 changes: 1 addition & 2 deletions man/checkPathForOutput.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ This is checked:
\item{Does no file under path \code{x} exist?}
\item{Is \code{dirname(x)} writeable?}
}

A string without slashes is interpreted as a file in the current working directory.
Paths are relative to the current working directory.
}
\examples{
# Can we create a file in the tempdir?
Expand Down
2 changes: 1 addition & 1 deletion man/checkPercentage.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Depending on the function prefix:
a string with the error message.
}
\description{
Check if an argument is a percentage
This checks \code{x} to be numeric and in the range \code{[0,1]}.
}
\details{
This function does not distinguish between
Expand Down
2 changes: 1 addition & 1 deletion man/checkString.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Depending on the function prefix:
a string with the error message.
}
\description{
A string a scalar character vector.
A string is defined as a scalar character vector.
}
\details{
This function does not distinguish between
Expand Down
6 changes: 6 additions & 0 deletions man/checkVector.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ Check if an argument is a vector
testVector(letters, min.len = 1L, any.missing = FALSE)
}
\seealso{
Other atomicvector: \code{\link{assertAtomicVector}},
\code{\link{checkAtomicVector}},
\code{\link{testAtomicVector}};
\code{\link{assertAtomic}}, \code{\link{checkAtomic}},
\code{\link{testAtomic}}

Other basetypes: \code{\link{assertArray}},
\code{\link{checkArray}}, \code{\link{testArray}};
\code{\link{assertAtomicVector}},
Expand Down

0 comments on commit 2e8e854

Please sign in to comment.