A robust helper for extracting fields from a desc::desc object that
gracefully handles missing or undefined entries. Unlike the raw
desc$get() method, this function returns NULL instead of a named
character vector with NA when a field does not exist.
Arguments
- desc
A
desc::descobject (from the desc package).- field
Character. The name of the field to extract from the DESCRIPTION file.
Details
This prevents issues where missing DESCRIPTION fields appear as "NA"
strings or one-element named vectors (e.g. field_name = NA), ensuring
cleaner downstream assignments in project initialization.
Examples
if (FALSE) { # \dontrun{
d <- desc::desc("DESCRIPTION")
get_desc_field(d, "Title")
get_desc_field(d, "NonexistentField") # returns NULL
} # }