Skip to content

melt(, na.rm=T) doesn't handle NA-columns properly #1359

@mplatzer

Description

@mplatzer

The code

dt <- data.table(id=1:3, x=NA_character_, y=c('a', NA_character_, 'c'))
melt(dt, id.var='id', na.rm=TRUE)

produces in data.table v1.9.4

   id variable value
1:  1        y     a
2:  3        y     c

but in data.table v.1.9.6 incorrectly returns

   id variable value
1:  1       NA     a
2:  3       NA     c

It seems the bug only occurs when melt is called with na.rm=TRUE on a data.table with a column that purely consists of NA-values. Also note, that the bug does not occur, when the NA-column is the last column of the data.table.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions