element_types: Gets the type of each element

View source: R/element_descriptors.R

element_typesR Documentation

Gets the type of each element

Description

\Sexpr[results=rd, stage=render]{lifecycle::badge("experimental")}

Applies typeof() to each element of `x` (without recursion).

Usage

element_types(x, keep_names = FALSE)

Arguments

x

List with elements.

keep_names

Whether to keep existing names. (Logical)

Details

Simple wrapper for unlist(lapply(x, typeof)).

Value

The type of each element.

Author(s)

Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk

See Also

Other element descriptors: element_classes(), element_lengths(), num_total_elements()

Examples

# Attach packages
library(xpectr)

l <- list("a" = c(1,2,3), "b" = "a", "c" = NULL)

element_types(l)
element_types(l, keep_names = TRUE)

xpectr documentation built on Nov. 18, 2022, 5:10 p.m.