Delete All Line Breaks from Character String in R (Example Code)
In this post you’ll learn how to delete newlines from a string in the R programming language.
Creation of Example Data
x <- "Hellooo\nWhat's going oooooon\nHeeeeere???" # Exemplifying character string |
x <- "Hellooo\nWhat's going oooooon\nHeeeeere???" # Exemplifying character string
Example: Apply gsub() Function to Remove Newlines from Character String
gsub("[rn]", "", x) # Deleting line breaks # [1] "HelloooWhat's going oooooonHeeeeere???" |
gsub("[rn]", "", x) # Deleting line breaks # [1] "HelloooWhat's going oooooonHeeeeere???"
Further Resources
Below, you can find some additional resources on topics such as loops, character strings, data conversion, and vectors: