From d3b5676c63f40782459b9dd3dcc2ea355fb0f3c4 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Tue, 25 Aug 2026 22:13:13 -0700 Subject: [PATCH] fix(createSSURGO): type conversion for logical column stored as Yes/No --- R/createSSURGO.R | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/R/createSSURGO.R b/R/createSSURGO.R index 35283828..ffbe4312 100644 --- a/R/createSSURGO.R +++ b/R/createSSURGO.R @@ -777,12 +777,25 @@ createSSURGO <- function(filename = NULL, character = as.character(y[[col]]), integer = suppressWarnings(as.integer(as.character(y[[col]]))), numeric = suppressWarnings(as.numeric(as.character(y[[col]]))), - logical = as.logical(y[[col]]) + logical = .as_logical_ssurgo(y[[col]]) ) } y } +# helper: consistent conversion of yes/no equivalents to logical +.as_logical_ssurgo <- function(x) { + lookup <- c( + "yes" = TRUE, "no" = FALSE, + "1" = TRUE, "0" = FALSE, + "true" = TRUE, "false" = FALSE, + "y" = TRUE, "n" = FALSE, + "t" = TRUE, "f" = FALSE + ) + x_out <- trimws(tolower(as.character(x))) + unname(lookup[x_out]) +} + # helper: fast delimited text reader .read_delim_tabular <- function(file, header,