A simple data frame extension that preserves attributes during subsetting operations.
cj_df(x) # S3 method for data.frame cj_df(x) # S3 method for cj_df [(x, i, j, drop = FALSE)
| x | A data frame  | 
    
|---|---|
| i | See   | 
    
| j | See   | 
    
| drop | Ignored.  | 
    
An data frame with additional “cj_df” class, which has subsetting methods that preserve variables attributes.
x1 <- data.frame(a = 1:3, b = 4:6) attr(x1$a, "label") <- "Variable A" # cj_df() returns a data frame inherits(x1, "data.frame")#> [1] TRUEclass(x1)#> [1] "data.frame"#> NULL#> [1] "Variable A"