-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
I have a transpose function that imitates the arguments used in SAS.
transpose = function(input, by, var){
melt(input, id.vars = by, measure.vars=var)
}
Function Call
transpose(myData, by="Year")
This function works if myData is a data frame, but it returns an error if myData is a data table.
Error in melt.data.table(input, id.vars = by, measure.vars = var) :
argument "var" is missing, with no default
This will work if I default var to a NULL value, but then the data frame version will result in an error.
My question is: Is there a reason for the inconsistency? It would be nice to have melt.data.table suppor missing arguments so that there is not a need for the programmer to check the class of myData.