View source: R/pathway_annotation.R
safe_extract | R Documentation |
Safely extracts elements from a list, returning NA if the extraction fails
safe_extract(list, field, index = 1)
list |
A list object from which to extract elements |
field |
The name of the field to extract from the list |
index |
The index position to extract from the field. Default is 1 |
The extracted element if successful, NA if extraction fails
# Create a sample list
my_list <- list(
a = list(x = 1:3),
b = list(y = 4:6)
)
# Extract existing element
safe_extract(my_list, "a", 1)
# Extract non-existing element (returns NA)
safe_extract(my_list, "c", 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.