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

extract_data() not returning a tibble when database = database$traits #144

Open
fontikar opened this issue Dec 19, 2024 · 0 comments
Open

Comments

@fontikar
Copy link
Collaborator

Describe the bug
Currently extract_data currently accepts the traits table in the database argument and extraction will operate on this table directly. Once extraction takes, extract_data, the function will assign the class to the returned object as a 'traits.build'. This means that the print.traits.build function will display the summary and show. 0 traits 0 taxa are extracted, but that is because the print function works with the entire traits.build database.

To Reproduce
Steps to reproduce the behavior:

library(austraits)
#> Loading required package: RefManageR
#> Thanks for showing interest in `austraits`! Please consider citing this package
#> - citation('austraits')

dataset_id = "Falster_2003"

extracted <- extract_data(database = austraits:::austraits_5.0.0_lite$traits, col = "dataset_id", col_value = dataset_id)

extracted
#> 
#> ── This database contains a total of  records, for 0 taxa and 0 traits. ────────
#> 
#> ── This object is a 'list' with the following components: ──
#> 
#> • traits: A table containing measurements of traits.
#> • locations: A table containing observations of location/site characteristics
#> associated with information in `traits`. Cross referencing between the two
#> dataframes is possible using combinations of the variables `dataset_id`,
#> `location_name`.
#> • contexts: A table containing observations of contextual characteristics
#> associated with information in `traits`. Cross referencing between the two
#> dataframes is possible using combinations of the variables `dataset_id`,
#> `link_id`, and `link_vals`.
#> • methods: A table containing details on methods with which data were
#> collected, including time frame and source. Cross referencing with the `traits`
#> table is possible using combinations of the variables `dataset_id`,
#> `trait_name`.
#> • excluded_data: A table of data that did not pass quality test and so were
#> excluded from the master dataset.
#> • taxonomic_updates: A table of all taxonomic changes implemented in the
#> construction of AusTraits. Changes are determined by comapring against the APC
#> (Australian Plant Census) and APNI (Australian Plant Names Index).
#> • taxa: A table containing details on taxa associated with information in
#> `traits`. This information has been sourced from the APC (Australian Plant
#> Census) and APNI (Australian Plant Names Index) and is released under a CC-BY3
#> license.
#> • definitions: A copy of the definitions for all tables and terms. Information
#> included here was used to process data and generate any documentation for the
#> study.
#> • contributors: A table of people contributing to each study.
#> • sources: Bibtex entries for all primary and secondary sources in the
#> compilation.
#> • build_info: A description of the computing environment used to create this
#> version of the dataset, including version number, git commit and R
#> session_info.
#> ℹ To access a component, try using the $ e.g. austraits$traits

class(extracted) <- NULL

extracted |> as.data.frame() |> head()
#>     dataset_id        taxon_name observation_id             trait_name  value
#> 1 Falster_2003 Acacia floribunda             01              leaf_area    142
#> 2 Falster_2003 Acacia floribunda             01 leaf_inclination_angle     57
#> 3 Falster_2003 Acacia floribunda             02      leaf_compoundness simple
#> 4 Falster_2003 Acacia myrtifolia             03              leaf_area    319
#> 5 Falster_2003 Acacia myrtifolia             03 leaf_inclination_angle   66.1
#> 6 Falster_2003 Acacia myrtifolia             04      leaf_compoundness simple
#>   unit entity_type value_type basis_of_value replicates basis_of_record
#> 1  mm2  population       mean    measurement          3           field
#> 2  deg  population       mean    measurement          3           field
#> 3 <NA>     species       mode   expert_score       <NA>           field
#> 4  mm2  population       mean    measurement          3           field
#> 5  deg  population       mean    measurement          3           field
#> 6 <NA>     species       mode   expert_score       <NA>           field
#>   life_stage population_id individual_id repeat_measurements_id
#> 1      adult            02          <NA>                   <NA>
#> 2      adult            02          <NA>                   <NA>
#> 3      adult          <NA>          <NA>                   <NA>
#> 4      adult            01          <NA>                   <NA>
#> 5      adult            01          <NA>                   <NA>
#> 6      adult          <NA>          <NA>                   <NA>
#>   temporal_context_id source_id location_id entity_context_id plot_context_id
#> 1                <NA>      <NA>          01              <NA>            <NA>
#> 2                <NA>      <NA>          01              <NA>            <NA>
#> 3                <NA>      <NA>        <NA>              <NA>            <NA>
#> 4                <NA>      <NA>          02              <NA>            <NA>
#> 5                <NA>      <NA>          02              <NA>            <NA>
#> 6                <NA>      <NA>        <NA>              <NA>            <NA>
#>   treatment_context_id collection_date measurement_remarks method_id
#> 1                 <NA>       2000/2001                <NA>        01
#> 2                 <NA>       2000/2001                <NA>        01
#> 3                 <NA>       2000/2001                <NA>        01
#> 4                 <NA>       2000/2001                <NA>        01
#> 5                 <NA>       2000/2001                <NA>        01
#> 6                 <NA>       2000/2001                <NA>        01
#>   method_context_id     original_name
#> 1              <NA> Acacia floribunda
#> 2              <NA> Acacia floribunda
#> 3              <NA> Acacia floribunda
#> 4              <NA> Acacia myrtifolia
#> 5              <NA> Acacia myrtifolia
#> 6              <NA> Acacia myrtifolia

Created on 2024-12-19 with reprex v2.1.1

Expected behavior
Either to return the tibble and no summary or calling of print.traits.build function

OR

We modify the print.traits.build function to summarise the traits.table. I'm not thrilled with this option as the traits table is not a traits.build object

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

No branches or pull requests

1 participant