data.table() constructor accepts key= to determine the key() of the resulting table.
I think rowwiseDT() could do the same. Some other considerations:
- There's some back-compatibility risk if users are already creating tables with columns named
key
- It's no longer possible to create a table with a column named
key directly
- We could in principle allow
missing(key) to mean "column named key" and !missing(key) to be the key() setting
- It could be abused to create really confusing code:
rowwiseDT(
a = , b = , key = 'a',
2, 1,
1, 2
)
rowwiseDT(
a = , b = ,
2, key = 'a', 1,
1, 2
)
rowwiseDT(
a = , key = 'a', b = ,
2, 1,
1, 2
)
I would suggest a linter to discourage that -- key= should either be the first or last argument:
rowwiseDT(key = 'a',
a = , b = ,
2, 1,
1, 2
)
rowwiseDT(
a = , b = ,
2, 1,
1, 2,
key = 'a'
)
data.table()constructor acceptskey=to determine thekey()of the resulting table.I think
rowwiseDT()could do the same. Some other considerations:keykeydirectlymissing(key)to mean "column namedkey" and!missing(key)to be thekey()settingI would suggest a linter to discourage that --
key=should either be the first or last argument: