【发布时间】:2018-06-24 15:16:31
【问题描述】:
我想从 df$text 中搜索一些词,如果它们中的任何一个或这些词出现在推文中,我想将整行放在新的数据框中。实际上问题发生了,我搜索了关键字“pat”、“ppp”、“jui”、“jip”,但我得到的数据集包含具有这些关键字的用户名,但不包含推文。我想删除那些没有关键字的推文。 数据框如下所示:
screen_name | text
1| pat_bing | RT @timkaine: 22 school shootings in 2018. 3 in the last week. How many times must our hearts break hearing news like this - this time in…
2| artguroo | RT @RabiaBaluch: Khurram Nawaz Gandapur (Dr Tahir Qadir’s right-hand man and PAT/Minhaj-ul-Quran leader) abusing and threatening young girl…
3| ppp_007 | RT @atDavidHoffman: Before today’s shooting in Santa Fe, Texas, no one was talking about the NRA & gun control anymore. Except the Parkland…
4| jip_1 | RT @TravisAllen02: What do Republicans care more about?
5| esha_jip | I want jip to become the best party ever #jip #ppp #anp #pmln #pti
所需的df应该是这样的:
screen_name | text
2| artguroo | RT @RabiaBaluch: Khurram Nawaz Gandapur (Dr Tahir Qadir’s right-hand man and PAT/Minhaj-ul-Quran leader) abusing and threatening young girl…
5| esha_jip | I want jip to become the best party ever #jip #ppp #anp #pmln #pti
我已经提取完推文,只是想收拾一下这个烂摊子。救命!
【问题讨论】:
-
请附上您尝试过的任何代码。
-
我还没试过
标签: r dataframe search text words