R - readRDS() & load() fail to give identical data.tables as the original

后端 未结 4 2128
野趣味
野趣味 2021-02-13 13:44

Background

I tried to replace some CSV output files with rds files to improve efficiency. These are intermediate files that wi

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-13 14:21

    Probably, this has to do with pointers:

     attributes(aDT)
    $names
    [1] "a" "b"
    
    $row.names
     [1]  1  2  3  4  5  6  7  8  9 10
    
    $class
    [1] "data.table" "data.frame"
    
    $.internal.selfref
    
    
    > attributes(bDT)
    $names
    [1] "a" "b"
    
    $row.names
     [1]  1  2  3  4  5  6  7  8  9 10
    
    $class
    [1] "data.table" "data.frame"
    
    $.internal.selfref
    
    
    > attributes(bDF)
    $names
    [1] "a" "b"
    
    $row.names
     [1]  1  2  3  4  5  6  7  8  9 10
    
    $class
    [1] "data.frame"
    
    > attributes(aDF)
    $names
    [1] "a" "b"
    
    $row.names
     [1]  1  2  3  4  5  6  7  8  9 10
    
    $class
    [1] "data.frame"
    

    You can closely look at what's going using .Internal(inspect(.)) command:

    .Internal(inspect(aDT))
    
     .Internal(inspect(bDT))
    

提交回复
热议问题