r - extracting hashtags from tweets -
i trying perform sentiment analysis , facing small problem. using dictionary has hashtags , other junk value(shown below). has associated weight of hashtag. want extract hashtags , corresponding weight new data frame. there easy way it? have tried using regmatches, how giving output in list format , messing things up. input:
v1 v2 1 #fabulous 7.526 2 #excellent 7.247 3 superb 7.199 4 #perfection 7.099 5 #terrific 6.922 6 #magnificent 6.672
output:
v1 v2 1 #fabulous 7.526 2 #excellent 7.247 3 #perfection 7.099 4 #terrific 6.922 5 #magnificent 6.672
this code should work , give desired output data.frame
input<- data.frame(v1 = c("#fabulous","#excellent","superb","#perfection","#terrific","#magnificent"), v2 = c("7.526", "7.247" , "7.199", "7.099", "6.922", "6.672")) extracthashtags <- input[which(substr(input$v1,1,1) == "#"),] view(extracthashtags)
Comments
Post a Comment