Last active
August 9, 2023 11:32
-
-
Save TimTaylor/14a1867e6ca17c5ea833f377f4157446 to your computer and use it in GitHub Desktop.
dput_raw ish type thing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
funz <- function(x) { | |
if (!is.character(x) || length(x) != 1L || is.na(x)) | |
stop("`x` must be a scalar character that's not NA.") | |
middle <- character() | |
go <- TRUE | |
i <- 1L | |
while(go) { | |
exploded <- c(")", middle, "\"") | |
delim <- paste(exploded, collapse = "") | |
if (grepl(delim, x, fixed = TRUE)) { | |
middle <- rep.int("-", i) | |
i <- i + 1L | |
next | |
} | |
go <- FALSE | |
} | |
start <- exploded | |
start[1] <- "r\"" | |
start[length(start)] <- "(" | |
start <- paste(start, collapse = "") | |
cat(start, x, delim, "\n", sep = "") | |
invisible(x) | |
} |
Author
TimTaylor
commented
Aug 9, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment