Skip to content

Commit e12f726

Browse files
Refactored duplicated logic in setDT and [,:=] to use a helper function
1 parent 76eb5bd commit e12f726

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

R/fmelt.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ melt.data.table = function(data, id.vars, measure.vars, variable.name = "variabl
182182
value.name = "value", ..., na.rm = FALSE, variable.factor = TRUE, value.factor = FALSE,
183183
verbose = getOption("datatable.verbose")) {
184184
if (!is.data.table(data)) stopf("'data' must be a data.table")
185+
186+
# Validate id.vars
187+
if (any(is.na(id.vars) | id.vars == "")) {
188+
stopf("One or more values in 'id.vars' is invalid.")
189+
}
190+
185191
if (missing(id.vars)) id.vars=NULL
186192
if (missing(measure.vars)) measure.vars = NULL
187193
measure.sub = substitute(measure.vars)

0 commit comments

Comments
 (0)