Skip to content

Commit

Permalink
Merge pull request #579 from rdatasculptor/master
Browse files Browse the repository at this point in the history
Update nesting.R
  • Loading branch information
JohnCoene authored Oct 21, 2023
2 parents c7863c2 + 55b8d3d commit c5c7eb5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions R/nesting.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,30 @@ e_add_nested <- function(e, param, ..., .serie = NULL, .data = NULL) {
if (missing(e) || missing(param)) {
stop("missing e or param", call. = FALSE)
}

if(is.null(.data))
ds <- e$x$data
else
ds <- map_grps_(.data, e$x$tl)

for (i in seq_along(ds)) {
data <- ds[[i]] |>
dplyr::select(...)

data <- apply(data, 1, as.list)

for (j in seq_along(data)) {
if(!is.null(.serie) && .serie != j)
next

if (!e$x$tl) {
e$x$opts$series[[i]]$data[[j]][[param]] <- data[[j]]
for(k in seq_along(e$x$opts$series)){
if(!is.null(.serie) && .serie != k)
next
e$x$opts$series[[k]]$data[[j]][[param]] <- data[[j]]
}
} else {
for(k in seq_along(e$x$opts$options[[i]]$series)){
if(!is.null(.serie) && .serie != k)
next
e$x$opts$options[[i]]$series[[k]]$data[[j]][[param]] <- data[[j]]
}
}
Expand Down

0 comments on commit c5c7eb5

Please sign in to comment.