melt when id.vars = NULL
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start at the melt.data.table entry point and compare its handling of an explicit id.vars = NULL with reshape2::melt. Reproduce the data.table example, then verify that the requested behavior avoids the guessing warning and that the warning text no longer contains the reported typo.
Written by the indexing model from the issue text.
Description
melt a data.table where all variables are measure.vars without specifying id.vars or measure.vars, works fine, but triggers a (relevant and informative) warning*:
library(reshape2)
library(data.table)
dt <- data.table(x1 = 1, x2 = 2, x3 = 3)
melt(dt)
# variable value
# 1: x1 1
# 2: x2 2
# 3: x3 3
# Warning message:
# In melt.data.table(dt) :
# To be consistent with reshape2's melt, id.vars and measure.vars are internally guessed when both
# are 'NULL'. All non-numeric/integer/logical type columns are conisdered id.vars, which in this case
# are columns []. Consider providing at least one of 'id' or 'measure' vars in future.
"id.vars and measure.vars are [...] both [...] NULL". So let's try to set id.vars = NULL because the data contains measure.vars only:
melt(dt, id.vars = NULL)
Same warning.
Try similar in reshape2::melt; id/measure.vars not specified, generates a warning:
dt <- as.data.frame(dt)
melt(df)
# No id variables; using all as measure variables
# variable value
# 1 x1 1
# 2 x2 2
# 3 x3 3
Setting id.vars = NULL removes the warning:
melt(df, id.vars = NULL)
# variable value
# 1 x1 1
# 2 x2 2
# 3 x3 3
Should id.vars = NULL in data.table::melt work like in reshape2::melt, i.e. result in no "guessing" of id/measure.vars and no warning, "To be consistent with reshape2's melt"?
*Please note the typo in the warning: "conisdered" should be "considered"
- Dominant language
- R
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 14h 4m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Rdatatable/data.table
-
as.data.table() recurses without end on a survival::Surv object (or any data.frame carrying one) Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Rdatatable/data.table#7887 ·
-
consistency tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#7853 · 3 comments ·
-
internals
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#6938 · 1 comment ·
-
encoding fread
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#5179 · 8 comments ·
-
documentation programming
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#3199 · 3 comments ·
All issues in Rdatatable/data.table
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·