-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
questionFurther information is requestedFurther information is requested
Description
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.--- Hadley, http://adv-r.had.co.nz/Functions.html
data.table and bit therefore call up a C function to modify attributes in place:
# https://github.com/truecluster/bit/blob/master/R/attrutil.R
setattr <- function(x, which, value)
{
.Call(C_R_bit_set_attr, x, which, value)
invisible()
}/* 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.
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested