-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
programmingparameterizing queries: get, mget, eval, envparameterizing queries: get, mget, eval, env
Description
I am trying to create an alias function for .N, but run into an error that I think is caused by a data.table internal issue.
library(data.table)
test_df <- data.table(a = 1:3, b = c("a","a","b"))
get_n <- function() eval(quote(.N), parent.frame())
# Using get_n() alone works
test_df[, list(count = get_n()), by = b] # Works
#> b count
#> 1: a 2
#> 2: b 1
# Using it with another summary function fails
test_df[, list(count = get_n(), avg_a = mean(a)), by = b]
#> Error in q[[2L]]: subscript out of boundsMetadata
Metadata
Assignees
Labels
programmingparameterizing queries: get, mget, eval, envparameterizing queries: get, mget, eval, env