ropensci / openalexR

Getting bibliographic records from OpenAlex
https://docs.ropensci.org/openalexR/
Other
100 stars 21 forks source link

Note in CRAN submission #78

Closed massimoaria closed 4 months ago

massimoaria commented 1 year ago

@trangdata I am trying to submit the new version of openalexR accepted by rOpneSci to CRAN but there are numerous invalid links to fix and other notes to fix.

Here the link to submission log: https://win-builder.r-project.org/incoming_pretest/openalexR_1.0.2.9000_20230226_213508/Windows/00check.log

trangdata commented 1 year ago

Thank you for notifying me! Will look into this in the next couple days. 🙏🏜

maelle commented 1 year ago

@trangdata do you know of https://github.com/r-lib/urlchecker? It's super useful.

If you use https://usethis.r-lib.org/reference/use_release_issue.html to create an issue with a checklist for CRAN submission, urlchecker is one of the items (that's how I remember to run it myself).

trangdata commented 1 year ago

@maelle I remembered there was a tool like that but couldn't find it!!! use_release_issue was what I needed. Thank you!

maelle commented 1 year ago

it's the tool to remind us of all the tools :grin:

massimoaria commented 1 year ago

@trangdata the package returns an issue when I try to check it for CRAN submission.

library(openalexR)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(ggplot2)

jours <- oa_fetch(
  entity = "venues",
  works_count = ">500000",
  verbose = TRUE
) |>
  filter(is.na(publisher)|!grepl("Elsevier", publisher)) |>
  distinct(display_name, .keep_all = TRUE) |>
  select(jour = display_name, x_concepts) |>
  tidyr::unnest(x_concepts) |>
  filter(level == 0) |>
  left_join(concept_abbrev) |>
  mutate(abbreviation = gsub(" ", "<br>", abbreviation)) |>
  tidyr::complete(jour, abbreviation, fill = list(score = 0)) |>
  group_by(jour) |>
  mutate(
    color = if_else(score > 10, "#1A1A1A", "#D9D9D9"), # CCCCCC
    label = paste0("<span style='color:", color, "'>", abbreviation, "</span>")
  )
#> Requesting url: https://api.openalex.org/venues?filter=works_count%3A%3E500000
#> Getting 1 page of results with a total of 17 records...
#> Error in `tibble::as_tibble()` at openalexR/R/oa2df.R:539:4:
#> ! Column 3 must be named.
#> Use `.name_repair` to specify repair.
#> Caused by error in `repaired_names()`:
#> ! Names can't be empty.
#> ✖ Empty name found at location 3.

#> Backtrace:
#>      ▆
#>   1. ├─dplyr::mutate(...)
#>   2. ├─dplyr::group_by(...)
#>   3. ├─tidyr::complete(...)
#>   4. ├─dplyr::mutate(...)
#>   5. ├─dplyr::left_join(...)
#>   6. ├─dplyr::filter(...)
#>   7. ├─tidyr::unnest(...)
#>   8. ├─dplyr::select(...)
#>   9. ├─dplyr::distinct(...)
#>  10. ├─dplyr::filter(...)
#>  11. └─openalexR::oa_fetch(...)
#>  12.   └─openalexR::oa2df(...) at openalexR/R/oa_fetch.R:123:4
#>  13.     └─openalexR:::venues2df(data, verbose) at openalexR/R/oa2df.R:54:2
#>  14.       ├─tibble::as_tibble(c(sub_identical, sub_flat, sub_id, sub_rbind_dfs)) at openalexR/R/oa2df.R:539:4
#>  15.       └─tibble:::as_tibble.list(c(sub_identical, sub_flat, sub_id, sub_rbind_dfs))
#>  16.         └─tibble:::lst_to_tibble(x, .rows, .name_repair, col_lengths(x))
#>  17.           └─tibble:::set_repaired_names(...)
#>  18.             └─tibble:::repaired_names(...)
#>  19.               ├─tibble:::subclass_name_repair_errors(...)
#>  20.               │ └─base::withCallingHandlers(...)
#>  21.               └─vctrs::vec_as_names(...)
#>  22.                 └─vctrs (local) `<fn>`()
#>  23.                   └─vctrs:::validate_unique(names = names, arg = arg, call = call)
#>  24.                     └─vctrs:::stop_names_cannot_be_empty(names, call = call)
#>  25.                       └─vctrs:::stop_names(...)
#>  26.                         └─vctrs:::stop_vctrs(...)
#>  27.                           └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = vctrs_error_call(call))

jours |>
  ggplot() +
  aes(fill = jour, y = score, x = abbreviation, group = jour) +
  facet_wrap(~jour) +
  geom_hline(yintercept = c(45, 90), colour = "grey90", linewidth = 0.2) +
  geom_segment(
    aes(x = abbreviation, xend = abbreviation, y = 0, yend = 100),
    color = "grey95"
  ) +
  geom_col(color = "grey20") +
  coord_polar(clip = "off") +
  theme_bw() +
  theme(
    plot.background = element_rect(fill = "transparent", colour = NA),
    panel.background = element_rect(fill = "transparent", colour = NA),
    panel.grid = element_blank(),
    panel.border = element_blank(),
    axis.text = element_blank(),
    axis.ticks.y = element_blank()
  ) +
  ggtext::geom_richtext(
    aes(y = 120, label = label),
    fill = NA, label.color = NA, size = 3
  ) +
  scale_fill_brewer(palette = "Set1") +
  guides(fill = "none") +
  labs(y = NULL, x = NULL, title = "Journal clocks")
#> Error in ggplot(jours): object 'jours' not found

Created on 2023-03-27 with reprex v2.0.2

The same issue is also returned during the tests:

Error (test-oa2df.R:8): oa2df works <tibble_error_column_names_cannot_be_empty/tibble_error/rlang_error/error/condition> Error in tibble::as_tibble(c(sub_identical, sub_flat, sub_id, sub_rbind_dfs)): Column 3 must be named. Use .name_repair to specify repair. Caused by error in repaired_names(): ! Names can't be empty. x Empty name found at location 3.

trangdata commented 1 year ago

Thank you for reporting this issue @massimoaria! 🙏🏜 It looks like openalex changed publisher to host_organization, which can be either publisher or institution depending on type. I will make a PR to address this issue.

Do you know if openalex has a public change log somewhere? I couldn't find it.

trangdata commented 1 year ago

In the mean time, as Maëlle recommended, do you want to use usethis::use_release_issue to track the CRAN submission @massimoaria? 🌈