From e9d8a8ba2adc7feb79b614aea5b2e16cc1334297 Mon Sep 17 00:00:00 2001 From: rCarto Date: Thu, 2 May 2024 16:41:12 +0200 Subject: [PATCH] feat: allow submitting coords/data as tibbles see #128 --- R/utils.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/utils.R b/R/utils.R index 0674beb..9e90d14 100644 --- a/R/utils.R +++ b/R/utils.R @@ -98,7 +98,7 @@ input_table <- function(x, id) { call. = FALSE ) } - if (ncol(x) == 2 && is.numeric(x[, 1]) && is.numeric(x[, 2])) { + if (ncol(x) == 2 && is.numeric(x[, 1, drop = TRUE]) && is.numeric(x[, 2, drop = TRUE])) { rn <- row.names(x) if (is.null(rn)) { rn <- 1:lx @@ -106,8 +106,8 @@ input_table <- function(x, id) { x <- data.frame( id = rn, - lon = clean_coord(x[, 1]), - lat = clean_coord(x[, 2]) + lon = clean_coord(x[, 1, drop = TRUE]), + lat = clean_coord(x[, 2, drop = TRUE]) ) return(x) } else { @@ -251,9 +251,9 @@ input_route <- function(x, id, single = TRUE, all.ids = FALSE) { if (lx < 2) { stop('"loc" should have at least 2 rows.', call. = FALSE) } - if (ncol(x) == 2 && is.numeric(x[, 1]) && is.numeric(x[, 2])) { - lon <- clean_coord(x[, 1]) - lat <- clean_coord(x[, 2]) + if (ncol(x) == 2 && is.numeric(x[, 1, drop = TRUE]) && is.numeric(x[, 2, drop = TRUE])) { + lon <- clean_coord(x[, 1, drop = TRUE]) + lat <- clean_coord(x[, 2, drop = TRUE]) rn <- row.names(x) if (is.null(rn)) { rn <- 1:lx