Skip to content

Commit

Permalink
Deal with plot names containing an underscore
Browse files Browse the repository at this point in the history
Invisible the ggplot return
  • Loading branch information
ArthurBailly committed Nov 29, 2024
1 parent 5e7ccff commit 18cec95
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/subplot_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 18cec95

Please sign in to comment.