0

I want to make a new column to my dataset with twitterID's for each of the usernames. Using the rtweet package I can derive the ID's like this:

usr_df <- lookup_users(df2$Username) %>% 
  select(user_id, screen_name)

So I think my operation is fairly simple: I just want to add the correct twitterID to the correct username in one dataframe. I was playing around with inner_join without any success. Also, some of the rows contains NA's for the username.

Data set 1:

# A tibble: 6 x 2
  Name           Username       
  <chr>          <chr>          
1 ZiadAboultaif  ziad_aboultaif 
2 ScottAitchison ScottAAitchison
3 DanAlbas       DanAlbas       
4 JohnAldag      jwaldag        
5 OmarAlghabra   OmarAlghabra   
6 ShafqatAli     Shafqat_Ali_1  

# For reproducibility:
structure(list(Name = c("ZiadAboultaif", "ScottAitchison", "DanAlbas", 
"JohnAldag", "OmarAlghabra", "ShafqatAli"), Username = c("ziad_aboultaif", 
"ScottAAitchison", "DanAlbas", "jwaldag", "OmarAlghabra", "Shafqat_Ali_1"
)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
))

Data set 2:

  user_id    screen_name    
  <chr>      <chr>          
1 4568748862 ziad_aboultaif 
2 172004509  ScottAAitchison
3 16278177   DanAlbas       
4 335769776  jwaldag        
5 20199202   OmarAlghabra   
6 578640179  Shafqat_Ali_1 

# For reproducibility:
structure(list(user_id = c("4568748862", "172004509", "16278177", 
"335769776", "20199202", "578640179"), screen_name = c("ziad_aboultaif", 
"ScottAAitchison", "DanAlbas", "jwaldag", "OmarAlghabra", "Shafqat_Ali_1"
)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
))
Quantizer
  • 181
  • 8

0 Answers0