Learn R Programming

xpectr (version 0.4.4)

element_types: Gets the type of each element

Description

lifecycle::badge("experimental")

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

Usage

element_types(x, keep_names = FALSE)

Value

The type of each element.

Arguments

x

List with elements.

keep_names

Whether to keep existing names. (Logical)

Author

Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk

Details

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

See Also

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

Examples

Run this code
# Attach packages
library(xpectr)

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

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

Run the code above in your browser using DataLab