if (FALSE) {
# Converting a character string
input <- "result <- mean(sqrt(abs(rnorm(10, 0, 1))), na.rm = TRUE)"
output <- nested_to_pipe(input)
cat(output)
# Converting a file
# Create a temporary input file
input_file <- tempfile(fileext = ".R")
write("result <- mean(sqrt(abs(rnorm(10, 0, 1))), na.rm = TRUE)", input_file)
# Convert the file using nested_to_pipe
output_file <- nested_to_pipe(input_file)
# Check the converted file content
cat(readLines(output_file))
}
Run the code above in your browser using DataLab