Simplified dput() in R

后端 未结 7 1058
深忆病人
深忆病人 2020-12-02 15:24

I miss a way to add data to an SO answer in a transparent manner. My experience is that the structure object from dput() at times confuses inexperi

7条回答
  •  [愿得一人]
    2020-12-02 16:20

    There is also the read.so package, which I really like, in particular to read SO data. It works for tibbles as well.

    #devtools::install_github("alistaire47/read.so")
    Df <- data.frame(A = c(2, 2, 2, 6, 7, 8),
                     B = c("A", "G", "N", NA, "L", "L"),
                     C = c(1L, 3L, 5L, NA, NA, NA))
    
    read.so::write.so(Df)
    
    #> Df <- data.frame(
    #>   A = c(2, 2, 2, 6, 7, 8),
    #>   B = c("A", "G", "N", NA, "L", "L"),
    #>   C = c(1L, 3L, 5L, NA, NA, NA)
    #> )
    

提交回复
热议问题