Skip to content

Can't save patchwork object in a list column in data.table: a possible conflict between patchwork and data.table. #381

@person-c

Description

@person-c

see Rdatatable/data.table#6395 and https://stackoverflow.com/questions/77085628/out-of-bound-error-when-trying-to-combine-plots-using-data-table

r$> mtDT <- setDT(copy(mtcars))

    mtDT[, .(plot = list(ggplot(data = .SD) + geom_point(aes(x=wt, y=mpg)))), by=.(carb,am)][,
    .(list(patchwork::wrap_plots(plot))), by=am]
Error in `X[[i]]`:
! Index out of bounds
Run `rlang::last_trace()` to see where the error occurred.

r$> rlang::last_trace(drop = FALSE)
<error/rlang_error>
Error in `X[[i]]`:
! Index out of bounds
---
Backtrace:
     x
  1. +-...[]
  2. \-data.table:::`[.data.table`(...)
  3.   \-data.table (local) runlock(ans)
  4.     \-base::lapply(x, runlock, current_depth = current_depth + 1L)
  5.       \-data.table (local) FUN(X[[i]], ...)
  6.         \-base::lapply(x, runlock, current_depth = current_depth + 1L)
  7.           \-data.table (local) FUN(X[[i]], ...)
  8.             \-base::lapply(x, runlock, current_depth = current_depth + 1L)
  9.               +-X[[i]]
 10.               \-patchwork:::`[[.patchwork`(X, i)
 11.                 \-cli::cli_abort("Index out of bounds")
 12.                   \-rlang::abort(...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions