Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in count/100 : non-numeric argument to binary operator #35

Open
hack-r opened this issue Mar 21, 2024 · 1 comment · May be fixed by #39
Open

Error in count/100 : non-numeric argument to binary operator #35

hack-r opened this issue Mar 21, 2024 · 1 comment · May be fixed by #39

Comments

@hack-r
Copy link

hack-r commented Mar 21, 2024

Session Info
 setting  value
 version  R version 4.2.2 (2022-10-31)
 os       macOS Ventura 13.2.1
 system   x86_64, darwin17.0
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/Toronto
 date     2024-03-20
 rstudio  2023.09.1+494 Desert Sunflower (desktop)
 pandoc   NA
> mx_api_content(
+     from_date = "2013-01-01",
+     to_date = as.character(Sys.Date()),
+     clean = TRUE,
+     server = "medrxiv",
+     include_info = FALSE
+ )
Error in count/100 : non-numeric argument to binary operator
> mx_data <- mx_api_content(from_date = "2020-01-01",
+                           to_date = "2020-01-07")
Error in count/100 : non-numeric argument to binary operator
> if(interactive()){
+     mx_data <- mx_api_content(from_date = "2020-01-01",
+                               to_date = "2020-01-07")
+ }
Error in count/100 : non-numeric argument to binary operator

> preprint_data <- mx_api_content(server = "biorxiv")
Error in count/100 : non-numeric argument to binary operator
> preprint_data <- mx_api_content()
Error in count/100 : non-numeric argument to binary operator

Offhand, I can see that this is caused by a bad value of count, probably NA, null, or 0. I believe the same error has been included automatically in the docs.

I am guessing either something changed server-side or in a dependency that invalidated the lib's logic. I am writing a Python version now; will let you know if I find the problem and solution.

@nthun
Copy link

nthun commented May 3, 2024

I think the problem is caused in line 12 in the mx_api_content() function, because the retrieved value is a character, and floor() expects a number.

count <- details$messages[1, 6]
pages <- floor(count/100)

count <- as.numeric(details$messages[1, 6]) should solve it (it works for me). I created a PR.
#36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants