A wrapper around saveRDS to save nicheR_ellipsoid
or nicheR_community objects to a file. Includes a safety check
for overwriting existing files and ensures the file extension is .rds.
Arguments
- object
A
nicheR_ellipsoidornicheR_communityobject.- file
Character. The connection or name of the file where the object will be saved (usually ending in ".rds").
- overwrite
Logical. If
TRUE, an existing file at the specified path will be replaced. Default isFALSE.- ...
Additional arguments passed to
saveRDS.
Examples
# Build a simple ellipsoid to save
range_df <- data.frame(bio_1 = c(15, 25),
bio_12 = c(500, 1500))
ell <- build_ellipsoid(range = range_df)
#> Starting: building ellipsoidal niche from ranges...
#> Step: computing covariance matrix...
#> Step: computing additional ellipsoidal niche metrics...
#> Done: created ellipsoidal niche.
# Save to a temporary file
tmp <- tempfile(fileext = ".rds")
save_nicheR(ell, file = tmp)
# Overwrite the same file
save_nicheR(ell, file = tmp, overwrite = TRUE)