Hi. I didn't know about base::comment. Should use unknownr::unk(), shouldn't I!
Please raise a new feature request, or add it to this one : #2197 "A simple labels attribute like in the Hmisc package for variable descriptions" https://r-forge.r-project.org/tracker/index.php?func=detail&aid=2197&group_id=240&atid=978 Do we want labels, or comments, or both? Griffith Rees (cc'd)? Since comment<- will copy the whole table, we'd need setcomment() [or setlabel(), or both] to avoid that copy; adding to the set* family. > PS: is stopifnot(identical(DT1[DT1]$A, DT1[DT1]$A.1)) a buglet? Seems ok : > DT1 <- data.table(id = seq.int(1, 10), A = LETTERS[1:10], key = "id") > stopifnot(identical(DT1[DT1]$A, DT1[DT1]$A.1)) > comment(DT1$A) <- "A" > stopifnot(identical(DT1[DT1]$A, DT1[DT1]$A.1)) Error: identical(DT1[DT1]$A, DT1[DT1]$A.1) is not TRUE > str(DT1[DT1]$A) chr [1:10] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" > str(DT1[DT1]$A.1) atomic [1:10] A B C D ... - attr(*, "comment")= chr "A" > > 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 >> > > _______________________________________________ > datatable-help mailing list > [email protected] > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help > _______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
