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

add methods for CompadreDB objects or supress helper text #133

Open
wpetry opened this issue Dec 19, 2022 · 2 comments
Open

add methods for CompadreDB objects or supress helper text #133

wpetry opened this issue Dec 19, 2022 · 2 comments

Comments

@wpetry
Copy link
Collaborator

wpetry commented Dec 19, 2022

The print method for CompadreDB objects prints the tibble contained in the @data slot. This makes sense, but recent changes to the tibble print method include suggestions to view aspects of the data that don't work on CompadreDB objects. Possible solutions:

  1. Implement methods for viewing data that simply return the @data slot. This would mean that print(cdbobj, n = 100) would return print(cdbobj@data, n = 100) and so on for an expanded set of data-viewing functions. This seems to already be partially implemented with methods for nrow/ncol, but could be expanded to others likecolnames.
  2. Suppress the tibble helper text when a CompadreDB object is printed. Toggling these off would involve setting option(pillar.advice = FALSE) or playing with the experimental pillar::tbl_format_footer function.

reprex

> library(Rcompadre)
> comp <- cdb_fetch("compadre")
This is COMPADRE version 6.22.5.0 (release date May_11_2022)
See user agreement at https://compadre-db.org/Help/UserAgreement
See how to cite at https://compadre-db.org/Help/HowToCite
> comp
A COM(P)ADRE database ('CompadreDB') object with 760 SPECIES and 8851 MATRICES.

# A tibble: 8,851 × 59
   mat        MatrixID Speci…¹ Speci…² Commo…³ Kingdom Phylum Class
   <list>        <int> <chr>   <chr>   <chr>   <chr>   <chr>  <chr>
 1 <CompdrMt>   238259 Abies_… Abies … Balsam… Plantae Pinop… Pino…
 2 <CompdrMt>   238260 Abies_… Abies … Balsam… Plantae Pinop… Pino…
 3 <CompdrMt>   238261 Agave_… Agave … Caribb… Plantae Magno… Lili…
 4 <CompdrMt>   238262 Agave_… Agave … Caribb… Plantae Magno… Lili…
 5 <CompdrMt>   238263 Allium… Allium… NA      Plantae Magno… Lili…
 6 <CompdrMt>   238265 Arauca… Arauca… NA      Plantae Pinop… Pino…
 7 <CompdrMt>   238266 Arauca… Arauca… NA      Plantae Pinop… Pino…
 8 <CompdrMt>   238271 Ascoph… Ascoph… NA      Chroma… Heter… Phae…
 9 <CompdrMt>   238272 Ascoph… Ascoph… NA      Chroma… Heter… Phae…
10 <CompdrMt>   238273 Ascoph… Ascoph… NA      Chroma… Heter… Phae…
# … with 8,841 more rows, 51 more variables: Order <chr>,
#   Family <chr>, Genus <chr>, Species <chr>, Infraspecies <chr>,
#   InfraspeciesType <chr>, OrganismType <chr>, DicotMonoc <chr>,
#   AngioGymno <chr>, Authors <chr>, Journal <chr>,
#   SourceType <chr>, OtherType <chr>, YearPublication <chr>,
#   DOI_ISBN <chr>, AdditionalSource <chr>, StudyDuration <chr>,
#   StudyStart <chr>, StudyEnd <chr>, ProjectionInterval <chr>, …
# ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
> print(comp, n = 20)
Error in print.default(comp, n = 20) : invalid 'na.print' specification
> colnames(comp)
NULL
> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.6.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] Rcompadre_1.1.0

loaded via a namespace (and not attached):
 [1] lattice_0.20-45 popdemo_1.3-1   fansi_1.0.3    
 [4] utf8_1.2.2      grid_4.2.2      lifecycle_1.0.3
 [7] magrittr_2.0.3  pillar_1.8.1    rlang_1.0.6    
[10] cli_3.4.1       rstudioapi_0.14 Matrix_1.5-3   
[13] vctrs_0.5.1     tools_4.2.2     glue_1.6.2     
[16] compiler_4.2.2  pkgconfig_2.0.3 tibble_3.1.8   
[19] expm_0.999-6  
@wpetry wpetry changed the title add tidy methods for CompadreDB objects or supress helper text add methods for CompadreDB objects or supress helper text Jan 25, 2023
wpetry added a commit to wpetry/Rcompadre that referenced this issue Jan 25, 2023
@wpetry
Copy link
Collaborator Author

wpetry commented Jan 25, 2023

I'm having trouble figuring out how to implement a print method for CompadreDB/Rcompadre objects that allows users to pass arguments to print.tbl

@wpetry
Copy link
Collaborator Author

wpetry commented Jan 25, 2023

Checklist of base R methods to consider adding under this issue:

  • colnames
  • print
  • dropping mat column when using subset() or [
  • cbind and rbind

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

No branches or pull requests

1 participant