在R中使用regsubset进行变量选择

时间:2019-04-14 22:28:38

标签: r

我正在Tweets项目上,我提取了87个变量,现在我需要执行变量选择方法,所以我使用了正向子集选择。但是我遇到了一个错误。

 regfit.fwd = regsubsets(screen_name ~.,merge_tweets,method = "forward",
                    complete.cases(merge_tweets),nvmax = 15)

  Error in leaps.setup(x[, ii[reorder], drop = FALSE], y, wt, 
  force.in[reorder],  : NA/NaN/Inf in foreign function call (arg 4)

  > head(merge_tweets)
  X    user_id    status_id created_at    screen_name
  1 1 1339835893 1.090257e+18 1548772454 HillaryClinton
  2 2 1339835893 1.090002e+18 1548711688 HillaryClinton
  3 3 1339835893 1.089999e+18 1548710912 HillaryClinton
  4 4 1339835893 1.089994e+18 1548709837 HillaryClinton
  5 5 1339835893 1.089994e+18 1548709756 HillaryClinton
  6 6 1339835893 1.089994e+18 1548709738 HillaryClinton

 text
 1                                                                       On 
top of human suffering and lasting damage to our national parks, the Trump 
shutdown cost the economy $11 billion. End shutdowns as a political hostage- 
taking tactic. 
2    Hurricane Maria decimated trees and ecosystems in Puerto Rico. Para La 
Naturaleza's nurseries have made a CGI commitment to plant 750,000 trees in 
seven years. The team here has already grown 120,000 seedlings and planted 
30,000 trees.               source display_text_width is_quote is_retweet favorite_count 
retweet_count lang
1 Twitter Web Client                192    FALSE      FALSE          14324          
4168   en
2 Twitter Web Client                235    FALSE      FALSE          10684          
2526   en
3 Twitter Web Client                238    FALSE      FALSE          11423          
2089   en
4 Twitter Web Client                 34    FALSE      FALSE           1293           
113   en
5 Twitter Web Client                222    FALSE      FALSE           6641           
951   en
6 Twitter Web Client                214    FALSE      FALSE          12192          
2108   en
                                                 status_url            name     
location
 Hillary 
Clinton New York, NY
 Hillary 
Clinton New York, NY

description
1 2016 Democratic Nominee, SecState, Senator, hair icon. Mom, Wife, Grandma 
x2, lawyer, advocate, fan of walks in the woods & standing up for our 
democracy.
2 2016 Democratic Nominee, SecState, Senator, hair icon. Mom, Wife, Grandma 
x2, lawyer, advocate, fan of walks in the woods & standing up for our 
democracy.
                  url protected followers_count friends_count listed_count 
statuses_count
1    FALSE        24017203           784        
41782          10667
2      FALSE        24017203           784        
41782          10667
3      FALSE        24017203           784        
41782          10667
favourites_count account_created_at verified             profile_url      
profile_expanded_url
1             1138         1365530675     TRUE 
2             1138         1365530675     TRUE 
3             1138         1365530675     TRUE 

我删除了一些网址列,因为它不支持要发布的网址。如果有人能帮助我解决这个问题,那就太好了。 在此先感谢!

0 个答案:

没有答案