As mentioned in the comments by lukeA, setNames
can be used:
m <- c("blah", "foo")
test_dtb[ , setNames(list(mean(b), median(b)), m), by = id]
More Related Contents:
- Overlap join with start and end positions
- data.table vs dplyr: can one do something well the other can’t or does poorly?
- How to delete a row by reference in data.table?
- Why does X[Y] join of data.tables not allow a full outer join, or a left join?
- dplyr mutate/replace several columns on a subset of rows
- Proper/fastest way to reshape a data.table
- Data.table meta-programming
- data.table with two string columns of set elements, extract unique rows with each row unsorted
- Creating dummy variables in R data.table
- Why is plyr so slow?
- How to reorder data.table columns (without copying)
- Elegantly assigning multiple columns in data.table with lapply()
- Sort a data.table fast by Ascending/Descending order
- Join R data.tables where key values are not exactly equal–combine rows with closest times
- Using setDT inside a function
- How to add a index by set of data when using rbindlist?
- Why is as.Date slow on a character vector?
- Cleaning `Inf` values from an R dataframe
- How to group data.table by multiple columns?
- Apply a function to a subset of data.table columns, by column-indices instead of name
- Selecting a subset of columns in a data.table
- Merge overlapping ranges into unique groups, in dataframe
- add missing rows to a data table
- `dcast` with empty RHS [duplicate]
- Convert a data frame to a data.table without copy
- Row sums over columns with a certain pattern in their name
- data.table package in R 3.5 does not install
- paste two data.table columns
- Removing multiple columns from R data.table with parameter for columns to remove
- Fill option for fread