Skip to content

Instantly share code, notes, and snippets.

@jmbarbone
Last active June 20, 2024 16:27
Show Gist options
  • Save jmbarbone/ee08d7c711ada53d01748073e7145756 to your computer and use it in GitHub Desktop.
Save jmbarbone/ee08d7c711ada53d01748073e7145756 to your computer and use it in GitHub Desktop.
Replaces `!!rlang::sym("...")` with `.data$...`
invisible(lapply(
list.files(
path = ".",
pattern = "\\.(r|rmd|qmd)$",
full.names = TRUE,
recursive = TRUE,
ignore.case = TRUE
),
function(path) {
pat <- "!!rlang::sym[(]\"([a-zA-z0-9_]+)\"[)]"
x <- readLines(path)
m <- grep(pat, x)
if (!length(m)) {
return()
}
x[m] <- gsub(pat, ".data$\\1", x[m])
writeLines(x, path)
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment