# `fix_text()` is convenient to explore with a small example
fix_text("any(duplicated(rnorm(5)))")
fix_text("any(duplicated(rnorm(5)))
any(is.na(x))
")
# Setup for the example with `fix()`
destfile <- tempfile()
cat("
x = c(1, 2, 3)
any(duplicated(x), na.rm = TRUE)
any(duplicated(x))
if (any(is.na(x))) {
TRUE
}
any(
duplicated(x)
)", file = destfile)
fix(destfile)
cat(paste(readLines(destfile), collapse = "\n"))
Run the code above in your browser using DataLab