I would like to disable unnecessary additional new string characters in strings using R. For example, if I have a string:
"This is an example test string. \n \n \n"
I would like it to look like this:
"This is an example test string. \n"
Try
x <- gsub("\\n\\s*", "\n", x)
This searches for any new line followed by a space, and replaces it with one new line.