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

isCharLikeR Documentation

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.

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."

Value

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

Note

This function is most useful within other functions to control how that function handles a particular argument.

See Also

class, is.numeric, is.factor, is.character, is.integer, is.logical

Examples


## 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)

USGS-R/smwrBase documentation built on Oct. 18, 2022, 9:55 a.m.