writeLines(captureAll(expression(1+1), split = FALSE))
writeLines(captureAll(expression(1+1), split = TRUE))
writeLines(captureAll(parseText("search()"), split = FALSE))
writeLines(captureAll(parseText('1:2 + 1:3'), split = FALSE))
writeLines(captureAll(parseText("badname"), split = FALSE))
## Management of incomplete lines
captRes <- captureAll(parseText("1 +")) # Clearly an incomplete command
if (is.na(captRes)) cat("Incomplete line!
") else writeLines(captRes)
rm(captRes)
Run the code above in your browser using DataLab