In the tidyverse:= is an extension of =, it allows us to use !!, {}, sym(), enquo() etc on the lhs.
In data.table it's a bit different, as it's used mainly to overcome the fact that it's used in the j argument. It's also used in a somewhat similar way as in the tidyverse with (foo) := bar being similar to !!sym(foo) := bar.
In our case :
:= is strictly equivalent to = wherever = works, which means iris_tb[this := that] will be ultimately fed to the dot, and not to i.
Definitions :
We call an argument named when = is used, and unnamed if it's not (as is standard practice)
We call an argument labelled when := is used, and unlabelled if it's not
We call an argument specified if it is named or labelled, and unspecified it's neither
If used in the ... (most common usage) :
((foo)) := bar + baz will remove bar and baz from the table at the end of the transformation
{foo} := bar will be just as `{foo}` = bar
?is.numeric := log will work as a mutate_if
c("Sepal.Width", "Sepal.Length") := log and slct(<exprs>) := log will work as a mutate_at
if the rhs of the latter is list or data frame of the same amount of elements, it will be a multi assign in the zeallot style.
We'll have a join syntax too but will be developped in its own issue
In the
tidyverse
:=
is an extension of=
, it allows us to use!!
,{}
,sym()
,enquo()
etc on the lhs.In data.table it's a bit different, as it's used mainly to overcome the fact that it's used in the
j
argument. It's also used in a somewhat similar way as in the tidyverse with(foo) := bar
being similar to!!sym(foo) := bar
.In our case :
:=
is strictly equivalent to=
wherever=
works, which meansiris_tb[this := that]
will be ultimately fed to the dot, and not toi
.Definitions :
=
is used, and unnamed if it's not (as is standard practice):=
is used, and unlabelled if it's notIf used in the
...
(most common usage) :((foo)) := bar + baz
will removebar
andbaz
from the table at the end of the transformation{foo} := bar
will be just as`{foo}` = bar
?is.numeric := log
will work as amutate_if
c("Sepal.Width", "Sepal.Length") := log
andslct(<exprs>) := log
will work as amutate_at