# 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)
Run the code above in your browser using DataLab