From 52885b5b2d4cd477dde5e0574c1f187f826b49b9 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 24 Jan 2024 22:04:17 +0100 Subject: [PATCH] guard against `NA` point padding --- R/geom-label-repel.R | 5 +++-- R/geom-text-repel.R | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/R/geom-label-repel.R b/R/geom-label-repel.R index 4b5acc4..a5cc36d 100644 --- a/R/geom-label-repel.R +++ b/R/geom-label-repel.R @@ -231,8 +231,9 @@ makeContent.labelrepeltree <- function(x) { point.size <- point.size * .pt / .stroke / 20 # The padding around each point. - point.padding <- length_cm(x$point.padding) - point.padding[is.na(point.padding)] <- 0 + point.padding <- x$point.padding + if (is.na(point.padding)) point.padding <- to_unit(0) + point.padding <- length_cm(point.padding) min.segment.length <- length_cm(x$min.segment.length) diff --git a/R/geom-text-repel.R b/R/geom-text-repel.R index 504aeb4..e8e36bd 100644 --- a/R/geom-text-repel.R +++ b/R/geom-text-repel.R @@ -376,8 +376,9 @@ makeContent.textrepeltree <- function(x) { point.size <- point.size * .pt / .stroke / 20 # The padding around each point. - point.padding <- length_cm(x$point.padding) - point.padding[is.na(point.padding)] <- 0 + point.padding <- x$point.padding + if (is.na(point.padding)) point.padding <- to_unit(0) + point.padding <- length_cm(point.padding) min.segment.length <- length_cm(x$min.segment.length)