Skip to content

Commit

Permalink
use data.table:::shallow instead of copy
Browse files Browse the repository at this point in the history
  • Loading branch information
TysonStanley committed Jan 7, 2024
1 parent bd2d056 commit a73e865
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions R/fill.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dt_fill <- function(dt_, ..., id = NULL, .direction = c("down", "up", "downup",

dt_fill.default <- function(dt_, ..., id = NULL, .direction = c("down", "up", "downup", "updown"), immutable=TRUE){

if (isFALSE(is.data.table(dt_))){
if (isFALSE(data.table::is.data.table(dt_))){
dt_ <- data.table::as.data.table(dt_)
}

Expand All @@ -56,7 +56,7 @@ dt_fill.default <- function(dt_, ..., id = NULL, .direction = c("down", "up", "d
by <- substitute(id)

if (immutable)
dt_ <- copy(dt_)
dt_ <- data.table:::shallow(dt_)

dt_[, paste(dots) := lapply(.SD, fun), by = eval(by), .SDcols = dots][]
}
Expand Down
2 changes: 1 addition & 1 deletion R/separate.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ dt_separate.default <- function(dt_, col, into,

# checks and nse
if (isFALSE(is.data.table(dt_))) dt_ <- data.table::as.data.table(dt_)
if (isTRUE(immutable)) dt_ <- data.table::copy(dt_)
if (isTRUE(immutable)) dt_ <- data.table:::shallow(dt_)
if (dev) {
j <- col
} else {
Expand Down

0 comments on commit a73e865

Please sign in to comment.