I am trying to split sentences based on different criteria. I am looking to split some sentences after " is" and some after " never". I was able to split sentences based on either of these conditions but not both.
str <- matrix(c("This is line one", "This is not line one",
"This can never be line one"), nrow = 3, ncol = 1)
>str
[,1]
[1,] "This is line one"
[2,] "This is not line one"
[3,] "This can never be line one"
str2 <- apply(str, 1, function (x) strsplit(x, " is", fixed = TRUE))
> str2
[[1]]
[[1]][[1]]
[1] "This" " line one"
[[2]]
[[2]][[1]]
[1] "This" " not line one"
[[3]]
[[3]][[1]]
[1] "This can never be line one"
I would like to split the last sentence after " never". I am not sure how to do that.