on-internet
← Community

How to cut all Lines/Characters in R after specific Characters

Stack Overflow ·

I am currently taking a course that teaches textual analysis in R. As I am fairly new to R, I could not figure out yet how to cut all Lines after a specific set of characters. For example, I have the following given: documentName <- "Hello my name is Johann my had is the largest to be deleted X" My desired outcome is: documentName <- "Hello my name is Johann" So far I have tried the following but it is not getting me anywhere. gsub("(\Johann).*\\","",documentName)

Comments

Sign in or sign up to comment and upvote.

No comments yet.