Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

has_length

How long is an object?


Description

This is a function for the common task of testing the length of an object. It checks the length of an object in a non-generic way: base::length() methods are ignored.

Usage

has_length(x, n = NULL)

Arguments

x

A R object.

n

A specific length to test x with. If NULL, has_length() returns TRUE if x has length greater than zero, and FALSE otherwise.

Examples

has_length(list())
has_length(list(), 0)

has_length(letters)
has_length(letters, 20)
has_length(letters, 26)

rlang

Functions for Base Types and Core R and 'Tidyverse' Features

v0.4.11
MIT + file LICENSE
Authors
Lionel Henry [aut, cre], Hadley Wickham [aut], mikefc [cph] (Hash implementation based on Mike's xxhashlite), Yann Collet [cph] (Author of the embedded xxHash library), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.