fix #517 and #518, empty data and empty img tags
- return NULL if x is empty/null, no need to try to plot something
- check for this NULL when saving to html or latex
diff --git a/R/column_spec.R b/R/column_spec.R
index 25d1289..14c0ea1 100644
--- a/R/column_spec.R
+++ b/R/column_spec.R
@@ -264,7 +264,7 @@
extra_css)
}
- if (!is.null(image)) {
+ if (!is.null(image) && (length(image) > 1 || !is.null(image[[1]]))) {
image <- image[[1]]
if (inherits(image, "kableExtraInlinePlots")) {
if (!is.null(image$svg_text)) {
@@ -539,7 +539,7 @@
new_row[column], "\\}")
}
- if (!is.null(image)) {
+ if (!is.null(image) && (length(image) > 1 || !is.null(image[[1]]))) {
image <- image[[1]]
if (inherits(image, "kableExtraInlinePlots")) {
new_row[column] <- paste0(
diff --git a/R/mini_plots.R b/R/mini_plots.R
index e1c65d3..1c15262 100644
--- a/R/mini_plots.R
+++ b/R/mini_plots.R
@@ -46,6 +46,8 @@
)}))
}
+ if (is.null(x)) return(NULL)
+
if (is.null(lim)) {
lim <- base::range(x)
}
@@ -147,6 +149,8 @@
)}))
}
+ if (is.null(x)) return(NULL)
+
if (is.null(lim)) {
lim <- base::range(x)
lim[1] <- lim[1] - (lim[2] - lim[1]) / 10
@@ -284,6 +288,8 @@
}, x, y))
}
+ if (is.null(x)) return(NULL)
+
if (is.null(y) || !length(y)) {
y <- x
x <- seq(0, 1, length.out = length(y))