From 78919d6e8e104f68be92b767b2b85f4805cb3b27 Mon Sep 17 00:00:00 2001 From: Michael Sumner Date: Tue, 22 Oct 2024 01:03:38 +0000 Subject: [PATCH] prevent error when no vars --- DESCRIPTION | 2 +- R/nc_meta.R | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3124fbf..3b3957f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ncmeta Title: Straightforward 'NetCDF' Metadata -Version: 0.4.0.9001 +Version: 0.4.0.9002 Authors@R: c(person("Michael", "Sumner", email = "mdsumner@gmail.com", role = c("aut", "cre")), person("Tomas", "Remenyi", role = "ctb"), person("Ben", "Raymond", role = "ctb"), diff --git a/R/nc_meta.R b/R/nc_meta.R index 90e40eb..f6b914f 100644 --- a/R/nc_meta.R +++ b/R/nc_meta.R @@ -29,8 +29,11 @@ nc_meta <- function(x, ...) { nc_meta.NetCDF <- function(x, ...) { inq <- nc_inq(x) dims <- nc_dims_internal(x, inq$ndims) - + if (inq$nvars > 0) { vars <- nc_vars_internal(x, inq$nvars) + } else { + vars <- tibble::tibble() + } if (nrow(vars) > 1) axis <- nc_axes(x, vars$name) else axis <- nc_axes(x) ## does a dimension have dim-vals?