Last active
September 22, 2021 12:34
-
-
Save brodieG/85271ef3de82509ad036 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DT[ | |
id %in% 200:300, | |
.(reg.val = sum(value)), | |
by=region | |
][ | |
reg.val > 0, | |
range(reg.val) | |
] |
"Each data.table query in a separate row." -- Good point!
I add one space before and after the square brackets, which may arguablly improve the readability a little bit. (the ][
pair loods weird if they stick together):
DT [ id %in% 200:300, .(reg.val = sum(value)), by= region
] [ reg.val > 0, range(reg.val) ]
(Also put a space after by=
, which I consider as a key word.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another good option, useful for longer chains:
Each data.table query in a separate row.