[datatable-help] Preserving comments in [.data.table?

Allan Engelhardt allane at cybaea.com
Tue Sep 11 11:09:59 CEST 2012


On 11/09/12 09:47, I wrote:
> I like comments, but [.data.table drops them, e.g.

More specifically, it drops them for the 'outer' data.table but not the 
inner (!?) when doing the join:

DT1 <- data.table(id = seq.int(1, 10), A = LETTERS[1:10], key = "id")
comment(DT1$A) <- "A"
DT2 <- data.table(id = seq.int(2, 10, 2), b = letters[1:5], key = "id")
comment(DT2$b) <- "b"
str(DT1[DT2]) # No comment on A
str(DT2[DT1]) # No comment on b

Allan

PS: is stopifnot(identical(DT1[DT1]$A, DT1[DT1]$A.1)) a buglet?

>
> DT1 <- data.table(A = 1:10)
> comment(DT1$A) <- "Documenting A column"
> DT2 <- DT1[A %% 2]
> stopifnot(identical(comment(DT1$A), comment(DT2$A)))
>
> Is there any way of preserving the comments? (My normal use case is 
> DT1 <- DT1[...] so copying from one to the other is a little ... 
> tedious?)
>
> Allan
>



More information about the datatable-help mailing list