The attr(x, "attrname") <- form looks like it modifies-in-place, but it actually doesn't:
Replacement functions act like they modify their arguments in place, and have the special name xxx<-. [...] I say they “act” like they modify their arguments in place, because they actually create a modified copy. [...] Built-in functions that are implemented using .Primitive() will modify in place.
/* https://github.com/truecluster/bit/blob/master/src/attrutil.c */
void R_bit_set_attr(SEXP x, SEXP which, SEXP value)
{
/* xx looking at R sources setAttrib would directly accept a string, however this is not documented */
setAttrib(x, install(CHAR(STRING_ELT(which, 0))), value);
}
It might be worthwhile for me to do the same here, given that I expect tsv2label to be working with very large columns. I'll see how it goes with further testing on real datasets.
The
attr(x, "attrname") <-
form looks like it modifies-in-place, but it actually doesn't:data.table
andbit
therefore call up a C function to modify attributes in place:It might be worthwhile for me to do the same here, given that I expect tsv2label to be working with very large columns. I'll see how it goes with further testing on real datasets.