baytrends (version 1.1.0)

isCharLike: Test whether an object can be treated in a particular way

Description

Tests if an object can be treated as a character, to name something; as a date; as a grouping variable, has distinct values; or as a number.

Usage

isCharLike(x)

isDateLike(x)

isGroupLike(x)

isNumberLike(x)

Arguments

x

any object.

Value

A logical value TRUE if x meets the criteria, or FALSE if it does not.

Details

The function isCharLike tests whether x is of class "character" or "factor." The function isDateLike tests whether x is of class "Date" or "POSIXt." The function isGroupLike tests whether x is of class "character" or "factor" or if x is of type "integer" or "logical." The function isNumberLike tests whether x is of type "numeric" or of class "Date."

Added from smwrBase.

Examples

Run this code
# NOT RUN {
## The first should be FALSE and the second TRUE
isCharLike(as.Date("2004-12-31"))
isCharLike("32")

## The first should be FALSE and the second TRUE
isDateLike(32)
isDateLike(as.Date("2004-12-31"))

## The first should be FALSE and the second TRUE
isGroupLike(as.Date("2004-12-31"))
isGroupLike(32)

## The first should be FALSE and the second TRUE
isNumberLike(as.Date("2004-12-31"))
isNumberLike(32)
# }

Run the code above in your browser using DataLab