From 61db0b87360ba15aa03fce8ff4d24042bfa9965b Mon Sep 17 00:00:00 2001 From: Pyry Kantanen Date: Thu, 17 Aug 2023 14:43:08 +0300 Subject: [PATCH] Make function usable without sf package --- R/get_eurostat_geospatial.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/R/get_eurostat_geospatial.R b/R/get_eurostat_geospatial.R index 7bd8b4ff..b974aafd 100755 --- a/R/get_eurostat_geospatial.R +++ b/R/get_eurostat_geospatial.R @@ -273,8 +273,15 @@ get_eurostat_geospatial <- function(output_class = "sf", # to df if (output_class == "df") { - # Remove geometry - shp <- sf::st_drop_geometry(shp) + # nocov start + if (!requireNamespace("sf", quietly = TRUE)) { + # Remove geometry without sf package + shp$geometry <- NULL + # nocov end + } else { + # Remove geometry + shp <- sf::st_drop_geometry(shp) + } } return(shp)