Skip to content
This repository has been archived by the owner on Nov 10, 2024. It is now read-only.

get_friends() fails for all user_ids if any one user_id is protected/missing/etc. #443

Closed
AltfunsMA opened this issue Sep 7, 2020 · 5 comments

Comments

@AltfunsMA
Copy link

AltfunsMA commented Sep 7, 2020

Problem

If any user_id or screen_name does not return values for whatever reason; the response parsing inside get_friends throws an error and the function returns nothing, regardless of whether other user_ids were queried successfully. Issue #339 describes this problem, but the title suggests it's just an inconvenience for users of the function downstream, rather than the function itself failing unexpectedly. The function works correctly if parse = FALSE is set; but the default is TRUE.

Expected behavior

The default behaviour for get_friends should ignore user_ids whose query fails, and return query values for other user_ids. That seems to be the intention given that the function first returns a warning and only later throws an error.

Reproduce the problem

Below one example for a missing user (probably a deleted account) paired with another that allows collection. #339 contains other examples.

rtweet::get_friends(c("796572560821485568", "BarackObama"), token = tk)
Warning: 34 - Sorry, that page does not exist.
Warning: ^^ warning regarding user: 796572560821485568
1 friend networks collected!
Error: Must extract column with a single valid subscript.
x Subscript `grep("id$", names(x))[1]` can't be `NA`.
Run `rlang::last_error()` to see where the error occurred.

rtweet version

0.7.0

Session info

R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6     fansi_0.4.1      assertthat_0.2.1 crayon_1.3.4    
 [5] later_1.0.0      R6_2.4.1         lifecycle_0.2.0  jsonlite_1.6.1  
 [9] magrittr_1.5     pillar_1.4.4     httr_1.4.1       cli_2.0.2       
[13] rlang_0.4.6      curl_4.3         rstudioapi_0.11  promises_1.1.0  
[17] rtweet_0.7.0     vctrs_0.3.0      ellipsis_0.3.1   tools_3.6.3     
[21] glue_1.4.1       httpuv_1.5.2     compiler_3.6.3   pkgconfig_2.0.3 
[25] askpass_1.1      openssl_1.4.2    tibble_3.0.1  
@jeremy-koster
Copy link

Students of mine are also having trouble with the get_friends() function. In particular, if one of the screen_names in the vectors is associated with an account that follows no other accounts (i.e., friends_count == 0), then the whole function crashes and does not return an object.

@msoehren
Copy link

I am also struggling with this problem but it seems the package isn't maintained anymore?

@jeremy-koster
Copy link

It doesn't seem to have been updated lately. A workaround with my students has been to download the user information via lookup_users() and then subset out the accounts for which friends_count is zero.

@llrs llrs mentioned this issue Feb 15, 2021
@hadley
Copy link
Collaborator

hadley commented Feb 27, 2021

@jeremy-koster can you provide a reprex please?

@hadley
Copy link
Collaborator

hadley commented Feb 27, 2021

Duplicate of #339

@hadley hadley marked this as a duplicate of #339 Feb 27, 2021
@hadley hadley closed this as completed Feb 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants