From 3222b7842861c83960aa7205da748a054a4ce09f Mon Sep 17 00:00:00 2001
From: Jason Fisher <jfisher@usgs.gov>
Date: Wed, 6 Dec 2023 00:09:20 -0800
Subject: [PATCH] tidy code

---
 R/make_data_release.R | 11 +++++++++--
 R/utils.R             |  1 -
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/R/make_data_release.R b/R/make_data_release.R
index e05c0f41..a554165f 100644
--- a/R/make_data_release.R
+++ b/R/make_data_release.R
@@ -85,6 +85,8 @@ make_data_release <- function(metadata,
   } else {
     rds <- parse_rd_db(package = package)
   }
+
+  # subset help documents
   rds <- rds[ds_names]
 
   # loop through datasets
@@ -113,13 +115,19 @@ make_data_release <- function(metadata,
     d <- rd$format_table
     if (!is.null(d)) {
 
-      # get information from dataset object
+      # get dataset object
       text <- paste(package, ds_names[i], sep = "::")
       ds <- parse(text = text) |> eval()
+
+      # uncompress packed spatial raster objects
       if (inherits(ds, "PackedSpatRaster")) {
         ds <- terra::unwrap(ds)
       }
+
+      # try to convert to a data frame
       ds <- try(as.data.frame(ds), silent = TRUE)
+
+      # describe column data
       if (is.data.frame(ds)) {
         if (!checkmate::test_subset(d$name, choices = colnames(ds))) {
           stop("Column name(s) do not match in dataset ", ds_names[i], call. = FALSE)
@@ -273,7 +281,6 @@ make_data_release <- function(metadata,
   file <- file.path(destdir, "metadata.xml", fsep = "/")
   xml2::as_xml_document(metadata) |> xml2::write_xml(file = file)
 
-
   # metadata validation
   if (validate) {
     file.path(destdir, "metadata.xml") |> validate_metadata(error = TRUE)
diff --git a/R/utils.R b/R/utils.R
index 43e63e8c..9479a8a4 100644
--- a/R/utils.R
+++ b/R/utils.R
@@ -1,4 +1,3 @@
-
 #' Append Dataset Name
 #'
 #' Append dataset name and provide status when creating datasets.
-- 
GitLab