Skip to content

Melt Function Inconsistency with reshape2 Version #780

@dardesta

Description

@dardesta

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.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions