How to handle binary strings in R?

前端 未结 2 1905
离开以前
离开以前 2020-12-29 11:56

R is not able to cope with null-strings (\\0) in characters, does anyone know how to handle this? More concrete, I want to store complex R objects within a database using an

2条回答
  •  我在风中等你
    2020-12-29 12:50

    A completely different approach would be to simply store the output of capture.output(dput(model)) along with a descriptive name and then reconstitute it with <- or assign(). See comments below regarding the need for capture.output().

    > dput(Mat1)
    structure(list(Weight = c(7.6, 8.4, 8.6, 8.6, 1.4), Date = c("04/28/11", 
    "04/29/11", "04/29/11", "04/29/11", "05/01/11"), Time = c("09:30 ", 
    "03:11", "05:32", "09:53", "19:52")), .Names = c("Weight", "Date", 
    "Time"), row.names = c(NA, -5L), class = "data.frame")
    > y <- capture.output(dput(Mat1))
    > y <- paste(y, collapse="", sep="")  # Needed because capture output breaks into multiple lines
    > dget(textConnection(y))
      Weight     Date   Time
    1    7.6 04/28/11 09:30 
    2    8.4 04/29/11  03:11
    3    8.6 04/29/11  05:32
    4    8.6 04/29/11  09:53
    5    1.4 05/01/11  19:52
    > new.Mat <- dget(textConnection(y))
    

提交回复
热议问题