Simplified dput() in R

后端 未结 7 1061
深忆病人
深忆病人 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:04

    The package datapasta won't always work perfectly as it currently doesn't support all types, but it is clean and easy, i.e.,

    # install.packages(c("datapasta"), dependencies = TRUE)    
    datapasta::dpasta(Df)
    #> data.frame(
    #>            A = c(2, 2, 2, 6, 7, 8),
    #>            C = c(1L, 3L, 5L, NA, NA, NA),
    #>            B = as.factor(c("A", "G", "N", NA, "L", "L"))
    #> )
    

提交回复
热议问题