From 18cec9596eef08ff8ee1be6c8d98af096242c02f Mon Sep 17 00:00:00 2001 From: ArthurBailly Date: Fri, 29 Nov 2024 16:30:13 +0100 Subject: [PATCH] Deal with plot names containing an underscore Invisible the ggplot return --- R/subplot_summary.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/subplot_summary.R b/R/subplot_summary.R index 435b33d..e4483dc 100644 --- a/R/subplot_summary.R +++ b/R/subplot_summary.R @@ -63,7 +63,9 @@ subplot_summary <- function(subplots, value = NULL, draw_plot = TRUE, fun = sum, if(any(duplicated(tree_summary$subplot_id))) { stop("the function supplied using `fun` must return a single value") } - tree_summary[,plot_id:=sapply(strsplit(tree_summary$subplot_id,"_"),function(x)x[[1]])] #Add plot_id to be able to loop on it + tree_summary[, plot_id:= #Add plot_id to be able to loop on it + sapply(strsplit(tree_summary$subplot_id,"_"), + function(x) paste(x[-((length(x)-1) : length(x))],collapse="_"))] # instead of function(x) x[1] in case plot_id contains any "_" sf_polygons <- do.call(rbind,lapply(split(corner_dat, by = "subplot_id"), function(dat) { @@ -111,7 +113,7 @@ subplot_summary <- function(subplots, value = NULL, draw_plot = TRUE, fun = sum, } print(plot_design) - plot_design + return(invisible(plot_design)) }) names(plot_list) <- unique(tree_summary$plot_id)