2016-10-13 7 views
-1

私はRプログラミングに全く興味がありません。 自分で学習しようとしています。 私はつぶやきの束を持っているようなシナリオを持っています。 と私はそれらのつぶやきを単語に基づいてフィルタリングしたい、それがそのつぶやきのテキストで終了する場合、それはすべてのつぶやきと他の属性を取得する必要があります。R条件に一致すると、つぶやくつぶやきR

sample.json

{"created_at":"Wed Oct 12 06:33:06 +0000 2016","id":786092312011112448,"id_str":"786092312011112448","text":"I posted a new photo to Google https:\/\/t.co\/5SBpo628DF","source":"\u003ca href=\"http:\/\/www.facebook.com\/twitter\" rel=\"nofollow\"\u003eFacebook\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":359430735,"id_str":"359430735","name":"Life Changing Quotes","screen_name":"dadhwalashish","location":"Jalandhar India","url":"http:\/\/www.CompassionKindness.com","description":"@armyofkind , Human Resources professional, Blogger, Happiness ambassador, Kindness warrior, Love agent, Humanity over all religion.","protected":false,"verified":false,"followers_count":1919,"friends_count":1973,"listed_count":41,"favourites_count":24456,"statuses_count":20738,"created_at":"Sun Aug 21 15:39:19 +0000 2011","utc_offset":19800,"time_zone":"New Delhi","geo_enabled":false,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/759986435453837312\/26b_K_9u_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/759986435453837312\/26b_K_9u_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/359430735\/1472921460","default_profile":true,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"urls":[{"url":"https:\/\/t.co\/5SBpo628DF","expanded_url":"http:\/\/fb.me\/1nqsSEAnu","display_url":"fb.me\/1nqsSEAnu","indices":[33,56]}],"user_mentions":[],"symbols":[]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"low","lang":"en","timestamp_ms":"1476253986729"} 
{"created_at":"Wed Oct 12 06:33:06 +0000 2016","id":786092312011112448,"id_str":"786092312011112448","text":"I posted a new photo to Google https:\/\/t.co\/5SBpo628DF","source":"\u003ca href=\"http:\/\/www.facebook.com\/twitter\" rel=\"nofollow\"\u003eFacebook\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":359430735,"id_str":"359430735","name":"Life Changing Quotes","screen_name":"dadhwalashish","location":"Jalandhar India","url":"http:\/\/www.CompassionKindness.com","description":"@armyofkind , Human Resources professional, Blogger, Happiness ambassador, Kindness warrior, Love agent, Humanity over all religion.","protected":false,"verified":false,"followers_count":1919,"friends_count":1973,"listed_count":41,"favourites_count":24456,"statuses_count":20738,"created_at":"Sun Aug 21 15:39:19 +0000 2011","utc_offset":19800,"time_zone":"New Delhi","geo_enabled":false,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/759986435453837312\/26b_K_9u_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/759986435453837312\/26b_K_9u_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/359430735\/1472921460","default_profile":true,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"urls":[{"url":"https:\/\/t.co\/5SBpo628DF","expanded_url":"http:\/\/fb.me\/1nqsSEAnu","display_url":"fb.me\/1nqsSEAnu","indices":[33,56]}],"user_mentions":[],"symbols":[]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"low","lang":"en","timestamp_ms":"1476253986729"}{"created_at":"Wed Oct 12 06:33:06 +0000 2016","id":786092312011112448,"id_str":"786092312011112448","text":"I posted a new photo to Facebook https:\/\/t.co\/5SBpo628DF","source":"\u003ca href=\"http:\/\/www.facebook.com\/twitter\" rel=\"nofollow\"\u003eFacebook\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":359430735,"id_str":"359430735","name":"Life Changing Quotes","screen_name":"dadhwalashish","location":"Jalandhar India","url":"http:\/\/www.CompassionKindness.com","description":"@armyofkind , Human Resources professional, Blogger, Happiness ambassador, Kindness warrior, Love agent, Humanity over all religion.","protected":false,"verified":false,"followers_count":1919,"friends_count":1973,"listed_count":41,"favourites_count":24456,"statuses_count":20738,"created_at":"Sun Aug 21 15:39:19 +0000 2011","utc_offset":19800,"time_zone":"New Delhi","geo_enabled":false,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/759986435453837312\/26b_K_9u_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/759986435453837312\/26b_K_9u_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/359430735\/1472921460","default_profile":true,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"urls":[{"url":"https:\/\/t.co\/5SBpo628DF","expanded_url":"http:\/\/fb.me\/1nqsSEAnu","display_url":"fb.me\/1nqsSEAnu","indices":[33,56]}],"user_mentions":[],"symbols":[]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"low","lang":"en","timestamp_ms":"1476253986729"} 
{"created_at":"Wed Oct 12 06:33:06 +0000 2016","id":786092312011112448,"id_str":"786092312011112448","text":"I posted a new photo to Google https:\/\/t.co\/5SBpo628DF","source":"\u003ca href=\"http:\/\/www.facebook.com\/twitter\" rel=\"nofollow\"\u003eFacebook\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":359430735,"id_str":"359430735","name":"Life Changing Quotes","screen_name":"dadhwalashish","location":"Jalandhar India","url":"http:\/\/www.CompassionKindness.com","description":"@armyofkind , Human Resources professional, Blogger, Happiness ambassador, Kindness warrior, Love agent, Humanity over all religion.","protected":false,"verified":false,"followers_count":1919,"friends_count":1973,"listed_count":41,"favourites_count":24456,"statuses_count":20738,"created_at":"Sun Aug 21 15:39:19 +0000 2011","utc_offset":19800,"time_zone":"New Delhi","geo_enabled":false,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/759986435453837312\/26b_K_9u_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/759986435453837312\/26b_K_9u_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/359430735\/1472921460","default_profile":true,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"urls":[{"url":"https:\/\/t.co\/5SBpo628DF","expanded_url":"http:\/\/fb.me\/1nqsSEAnu","display_url":"fb.me\/1nqsSEAnu","indices":[33,56]}],"user_mentions":[],"symbols":[]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"low","lang":"en","timestamp_ms":"1476253986729"}{"created_at":"Wed Oct 12 06:33:06 +0000 2016","id":786092312011112448,"id_str":"786092312011112448","text":"I posted a new photo to Google https:\/\/t.co\/5SBpo628DF","source":"\u003ca href=\"http:\/\/www.facebook.com\/twitter\" rel=\"nofollow\"\u003eFacebook\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":359430735,"id_str":"359430735","name":"Life Changing Quotes","screen_name":"dadhwalashish","location":"Jalandhar India","url":"http:\/\/www.CompassionKindness.com","description":"@armyofkind , Human Resources professional, Blogger, Happiness ambassador, Kindness warrior, Love agent, Humanity over all religion.","protected":false,"verified":false,"followers_count":1919,"friends_count":1973,"listed_count":41,"favourites_count":24456,"statuses_count":20738,"created_at":"Sun Aug 21 15:39:19 +0000 2011","utc_offset":19800,"time_zone":"New Delhi","geo_enabled":false,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/759986435453837312\/26b_K_9u_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/759986435453837312\/26b_K_9u_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/359430735\/1472921460","default_profile":true,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"urls":[{"url":"https:\/\/t.co\/5SBpo628DF","expanded_url":"http:\/\/fb.me\/1nqsSEAnu","display_url":"fb.me\/1nqsSEAnu","indices":[33,56]}],"user_mentions":[],"symbols":[]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"low","lang":"en","timestamp_ms":"1476253986729"} 
{"created_at":"Wed Oct 12 06:33:06 +0000 2016","id":786092312011112448,"id_str":"786092312011112448","text":"I posted a new photo to Twiiter https:\/\/t.co\/5SBpo628DF","source":"\u003ca href=\"http:\/\/www.facebook.com\/twitter\" rel=\"nofollow\"\u003eFacebook\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":359430735,"id_str":"359430735","name":"Life Changing Quotes","screen_name":"dadhwalashish","location":"Jalandhar India","url":"http:\/\/www.CompassionKindness.com","description":"@armyofkind , Human Resources professional, Blogger, Happiness ambassador, Kindness warrior, Love agent, Humanity over all religion.","protected":false,"verified":false,"followers_count":1919,"friends_count":1973,"listed_count":41,"favourites_count":24456,"statuses_count":20738,"created_at":"Sun Aug 21 15:39:19 +0000 2011","utc_offset":19800,"time_zone":"New Delhi","geo_enabled":false,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/759986435453837312\/26b_K_9u_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/759986435453837312\/26b_K_9u_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/359430735\/1472921460","default_profile":true,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"urls":[{"url":"https:\/\/t.co\/5SBpo628DF","expanded_url":"http:\/\/fb.me\/1nqsSEAnu","display_url":"fb.me\/1nqsSEAnu","indices":[33,56]}],"user_mentions":[],"symbols":[]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"low","lang":"en","timestamp_ms":"1476253986729"} 

Words.txt

google 
facebook 
twitter 

Googleの単語がある場合のつぶやきで存在する:テキスト、それはその単語が含まれているすべてのつぶやきを取得する必要がありますし、残りの単語と同じです。 私はそれを自分で試していますが、専門家の助言が必要です。 それを行う最善の方法は何ですか。

ありがとうございます。 Mohan.Vあなたはこのような何かを始めることができ

+0

こんにちは、StackOverflowのへの歓迎します。ヘルプページ、特に[ここではどのトピックについて聞かせていただけますか?](http://stackoverflow.com/help/on-topic)と[質問しないでください。」](http://stackoverflow.com/help/dont-ask)。さらに重要なことは、[Stack Overflow question checklist](http://meta.stackexchange.com/q/156810/204922)をお読みください。また、[最小、完全、および検証可能な例](http://stackoverflow.com/help/mcve)についても知りたいことがあります。 – symbolrush

答えて

0

:しかし、私は強くあなたが(a)は、非常にSOのガイドラインやルールを見てみると、(b)ことを示唆している

# words to match 
words <- c("google","facebook","twitter") 
# sample words. put real jsons here 
sample.jsons <- c("google","twitch","twitter","twitch","facebook","twitch","google","facebook","twitter") 
# run through all jsons and target words 
for(i in seq_along(sample.jsons)){ 
    for(j in seq_along(words)){ 
    # if this condition is TRUE, your criteria is fullfilled 
    if(words[[j]] %in% sample.jsons[[i]]){ 
     # do whatever you want with the jsons which match your criteria 
     # right now the following command just outputs all index values at which the criteria is fulfilled 
     print(i) 
    } 
    } 
} 

Rプログラミングの基本は続行する前に。なぜなら、あなたはすぐに次の問題を起こす可能性が高いからです。開始する

良い場所は以下のとおりです。ノーマン・マットロフによって

+0

@バニーこの回答が役に立った場合は、チェックマークをクリックして回答を選択してください。これにより、回答者の回答がコミュニティに伝えられ、問題は解決されます。 – jd1338

関連する問題