8

I am doing an analysis in r on tweets imported from a python script and have accidentally included the letter "b" before each tweet. It is the first character in one of the columns in the data frame. I have managed to clean up the tweets otherwise using the "stringr" package, does anyone know how to change this, in other words just get rid of the first character in the column usertweet? Here is some example code:

username = c("user1", "user2") 
usertweet= c("b something", "b something something") 
tweetsdf <-data.frame(username,usertweet) 
2
  • 3
    at least 5 down-votes are you kidding me? I'm starting to feel embarrassed to be a part of this community
    – rawr
    Jan 15, 2017 at 16:17
  • 3
    some loser whose feeling i have hurt has started downvoting some of my answers. you are only proving my point
    – rawr
    Jan 15, 2017 at 16:42

1 Answer 1

22

We can use substring

tweetsdf$usertweet <- substring(tweetsdf$usertweet, 3)

Or use sub

sub("\\S+\\s+", "", tweetsdf$usertweet)
2
  • so you got 3 downvotes for this answer?
    – rawr
    Jan 15, 2017 at 17:10
  • I am so sorry if I have gotten anyone in trouble! Thanks for the answer though it fixed my problem!
    – John
    Jan 15, 2017 at 17:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.