A wrapper around dput that facilitates saving R objects within knitr documents.
Automatically handles file naming and directory creation, with support for
preserving object structure and attributes.
write_obj(obj, file = NULL, target_dir = NULL, ...)The path of the written file.
This function extends dput functionality by:
Using knitr code block labels for automatic file naming
Creating target directories if they don't exist
Preserving complex object structures and attributes
Supporting all R object types (vectors, lists, data frames, etc.)
Objects saved with this function can be read back using the standard
dget function.