Amarjeet
Amarjeet

Reputation: 925

Efficient way to Split text data in R

I am working on text mining, Lets say my data set has the column having the Text data posted in twitter. e.g @john Its a fantastic work@lita checkout this is amazing @Amy great App

I want to check to split this to @john Its a fantastic work, @lita checkout this is amazing, @Amy great App

then i want to see who has posted originally and who has re-posted.

P.S: I am facing another problem while installing the 'sna' package in R, as it showing no such package.

Upvotes: 1

Views: 102

Answers (1)

akrun
akrun

Reputation: 887961

You can try

 strsplit(str1, '(?<=[^@]) ?(?=@)', perl=TRUE)[[1]]
#[1] "@john Its a fantastic work"     "@lita checkout this is amazing"
#[3] "@Amy great App"        

data

str1 <-  "@john Its a fantastic work@lita checkout this is amazing @Amy great App"

Upvotes: 4

Related Questions