luckinet/ontologics

Example in map new concepts not working

Closed this issue · 4 comments

rue-a commented

The new_source() function throws an error when executing the following example block.

# already existing ontology for some project about crops
crops <- load_ontology(path = system.file("extdata", "crops.rds", package = "ontologics"))

# where we have to set the external dataset as new source
crops <- new_source(name = "externalDataset",
                    description = "a vocabulary",
                    homepage = "https://www.something.net",
                    license = "CC-BY-4.0",
                    ontology = crops)

# new concepts that occur in the external dataset, which should be harmonised with the ontology
newConcepts <- c("Wheat", "NUTS", "Avocado")

I think this is caused by giving only 5 arguments to the function, where it actually has 6 arguments. The default value for the 6th argument (notes) is NULL, as we see in the function's head:

new_source <- function(name = NULL, description = NULL, homepage = NULL, license = NULL, notes = NULL, ontology = NULL)

Apparently, this leads to a conflict with the sources Data.Frame that expects to get a chr-type object for the notes column (at least that is what I get from the error :D). Here is the error stack:

Error: Internal error in `vec_proxy_assign_opts()`: `proxy` of type `character` incompatible with `value` proxy of type `NULL`.
Traceback:

1. new_source(name = "externalDataset", description = "a vocabulary", 
 .     homepage = "https://www.something.net", license = "CC-BY-4.0", 
 .     ontology = crops)
2. bind_rows(ontology@sources, newSource)   # at line 68 of file C:/Users/arner/Nextcloud/Projects/ontologics/R/new_source.R
3. vec_rbind(!!!dots, .names_to = .id)
4. (function () 
 . abort(message = message))()
5. abort(message = message)
6. signal_abort(cnd)

Strange. This shouldn't be happening. Maybe it's due to some other package not having the correct version. I don't get this error msg and also the github actions don't pick it up.

Could you please run sessionInfo()? Mine shows

> sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.utf8  LC_CTYPE=German_Germany.utf8    LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C                    LC_TIME=German_Germany.utf8    

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

other attached packages:
[1] ontologics_0.3.1

loaded via a namespace (and not attached):
 [1] rstudioapi_0.13  magrittr_2.0.3   hms_1.1.1        tidyselect_1.1.2 R6_2.5.1         rlang_1.0.2      fansi_1.0.3      stringr_1.4.0    dplyr_1.0.9     
[10] tools_4.2.0      checkmate_2.1.0  utf8_1.2.2       cli_3.3.0        DBI_1.1.2        ellipsis_0.3.2   assertthat_0.2.1 tibble_3.1.7     lifecycle_1.0.1 
[19] crayon_1.5.1     tidyr_1.2.0      purrr_0.3.4      readr_2.1.2      tzdb_0.3.0       vctrs_0.4.1      glue_1.6.2       stringi_1.7.6    compiler_4.2.0  
[28] pillar_1.7.0     generics_0.1.2   backports_1.4.1  pkgconfig_2.0.3

I might then have to declare clearer the import-section of the package...

rue-a commented

Hm. Then it is probably related to my environment. I run the code in a jupyter notebook from the top level folder and load the ontologics package with devtools. Let's investigate this when the restructuring of the package's internals is finished. For now, I append the sessionInfo (I'll try updating R today) and the contents of the notebook:

SessionInfo():

R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_Germany.1252  LC_CTYPE=English_Germany.1252   
[3] LC_MONETARY=English_Germany.1252 LC_NUMERIC=C                    
[5] LC_TIME=English_Germany.1252    

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

other attached packages:
[1] ontologics_0.3.1 tibble_2.1.3    

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.2        pillar_1.4.2      compiler_3.6.1    remotes_2.4.0    
 [5] prettyunits_1.0.2 base64enc_0.1-3   tools_3.6.1       testthat_3.0.3   
 [9] pkgload_1.2.1     pkgbuild_1.2.0    zeallot_0.1.0     digest_0.6.21    
[13] uuid_0.1-2        lifecycle_1.0.0   jsonlite_1.6      evaluate_0.14    
[17] memoise_2.0.0     checkmate_1.9.4   pkgconfig_2.0.2   rlang_0.4.11     
[21] rstudioapi_0.13   IRdisplay_0.7.0   cli_2.5.0         IRkernel_1.2     
[25] fastmap_1.1.0     withr_2.4.2       repr_1.1.3        dplyr_0.8.3      
[29] stringr_1.4.0     desc_1.3.0        vctrs_0.2.0       fs_1.5.0         
[33] hms_0.5.0         devtools_2.4.2    rprojroot_1.3-2   tidyselect_0.2.5 
[37] glue_1.3.1        R6_2.5.0          processx_3.5.2    sessioninfo_1.1.1
[41] pbdZMQ_0.3-3      callr_3.7.0       purrr_0.3.4       readr_1.3.1      
[45] tidyr_0.8.3       magrittr_2.0.1    usethis_2.0.1     ps_1.6.0         
[49] backports_1.1.4   htmltools_0.3.6   ellipsis_0.3.2    assertthat_0.2.1 
[53] stringi_1.4.3     cachem_1.0.5      crayon_1.3.4     

notebook:

devtools::load_all()
library(tibble)

# already existing ontology for some project about crops
crops <- load_ontology(path = system.file("extdata", "crops.rds", package = "ontologics"))

# where we have to set the external dataset as new source
crops <- new_source(name = "externalDataset",
                    description = "a vocabulary",
                    homepage = "https://www.something.net",
                    license = "CC-BY-4.0",
                    ontology = crops)

# new concepts that occur in the external dataset, which should be harmonised with the ontology
newConcepts <- c("Wheat", "NUTS", "Avocado")

Hm, I think you should, first of all, update your R installation, the current version is 4.2, and I think with that come many new updates, for instance in the tidyverse...

rue-a commented

Yeah, it apparently was a version issue.