Title: | Helpful functions to access the AusTraits database and wrangle data from other traits.build databases |
---|---|
Description: | `austraits` allow users to **access, explore and wrangle data** from traits.build relational databases. It is also an R interface to AusTraits, the Australian plant trait database. This package contains functions for joining data from various tables, filtering to specific records, combining multiple databases and visualising the distribution of the data. We expect this package will assist users in working with `traits.build` databases. |
Authors: | Daniel Falster [aut] , Elizabeth Wenk [ctb] , Fonti Kar [aut, cre] , Dony Indiarto [aut] |
Maintainer: | Fonti Kar <[email protected]> |
License: | MIT + file LICENSE |
Version: | 3.0.1 |
Built: | 2024-12-08 23:22:03 UTC |
Source: | https://github.com/traitecoevo/austraits |
Create a single wide table from a traits.build data object
as_wide_table(database)
as_wide_table(database)
database |
traits.build database (list object) |
A single wide table with collapsed contexts and locations text and with some cols renamed for alignment with other resources
## Not run: austraits %>% as_wide_table() ## End(Not run)
## Not run: austraits %>% as_wide_table() ## End(Not run)
bind_databases
binds all the listed studies into a single traits.build
database object as a large list.
bind_databases(..., databases = list(...))
bind_databases(..., databases = list(...))
... |
Arguments passed to other functions |
databases |
List of traits.build databases to be bond together |
Compiled database as a single large list
This function condenses data for studies that have multiple observations for a given trait into a single row. This function concatenates multiple values into a single cell
bind_trait_values(trait_data)
bind_trait_values(trait_data)
trait_data |
the traits table in a traits.build database – see example |
tibble that is condensed down where multiple observations in value, value_type and replicates are collapsed down and separated by '–'
Daniel Falster - [email protected]
## Not run: traits <- austraits$traits %>% dplyr::filter(dataset_id == "ABRS_1981") traits traits_bind <- bind_trait_values(traits) ## End(Not run)
## Not run: traits <- austraits$traits %>% dplyr::filter(dataset_id == "ABRS_1981") traits traits_bind <- bind_trait_values(traits) ## End(Not run)
Convert a dataframe to a named list, useful when converting a datafreme a to yaml.
convert_df_to_list(df)
convert_df_to_list(df)
df |
A dataframe |
A (yaml) list
convert_df_to_list(dplyr::starwars)
convert_df_to_list(dplyr::starwars)
Convert a list with a single level of entries to a dataframe, useful when converting a yaml into a dataframe.
convert_list_to_df1(my_list)
convert_list_to_df1(my_list)
my_list |
A list with single entries |
A tibble with two columns
## Not run: convert_list_to_df1(as.list(dplyr::starwars)[2]) ## End(Not run)
## Not run: convert_list_to_df1(as.list(dplyr::starwars)[2]) ## End(Not run)
Convert a list of lists to a dataframe, useful when converting a multi-level yaml into a dataframe. Function required that every list have same named elements.
convert_list_to_df2(my_list, as_character = TRUE, on_empty = NA)
convert_list_to_df2(my_list, as_character = TRUE, on_empty = NA)
my_list |
A list of lists to dataframe |
as_character |
A logical value, indicating whether the values are read as character |
on_empty |
Value to return if my_list is NULL, NA or is length == 0, default = NA |
tibble
demo_list1 <- list(word1 = "this", word2 = "is", word3 = "an", word4 = "example", word5 = "list") demo_list2 <- list(word1 = "and", word2 = "a", word3 = "second", word4 = "list", word5 = "also") combined_list <- list(demo_list1, demo_list2) convert_list_to_df2(combined_list)
demo_list1 <- list(word1 = "this", word2 = "is", word3 = "an", word4 = "example", word5 = "list") demo_list2 <- list(word1 = "and", word2 = "a", word3 = "second", word4 = "list", word5 = "also") combined_list <- list(demo_list1, demo_list2) convert_list_to_df2(combined_list)
Function to extract data from a traits.build database based on any value(s) from any column in the traits, locations, contexts, methods, taxa, taxonomic_updates, and contributors tables. The output a traits.build formatted database with all tables subset based on the specified table, column (variable) and column value.
extract_data(database, table = NA, col, col_value)
extract_data(database, table = NA, col, col_value)
database |
traits.build database (list object) |
table |
Table within a traits.build database |
col |
Column name within the specified table. |
col_value |
Value (of column, from with a table) that is used to subset database. This can be a single value or a vector. It includes partial string matches. |
subset traits.build database
## Not run: extract_data(database = traits.build_database, table = "traits", col = "trait_name", col_value = "leaf_area") ## End(Not run)
## Not run: extract_data(database = traits.build_database, table = "traits", col = "trait_name", col_value = "leaf_area") ## End(Not run)
Function to subset all data associated with a particular dataset from a traits.build relational database.
extract_dataset(database, dataset_id)
extract_dataset(database, dataset_id)
database |
traits.build database (list object) |
dataset_id |
character string that matches a |
extract_dataset
has been developed to extract data for specific datasets from databases built using the traits.build workflow.
Learn more at:
https://github.com/traitecoevo/traits.build &
https://github.com/traitecoevo/traits.build-book
Note to AusTraits users:
This function works with AusTraits version >= 5.0.0 (from Nov 2023 release)
For AusTraits versions <= 4.2.0 (up to Sept 2023 release) see https://github.com/traitecoevo/austraits for how to install old versions of the package or download a newer version of the database.
List of tibbles containing all traits.build data and metadata for the specified dataset(s).
Daniel Falster - [email protected]
## Not run: extract_dataset(database, "Falster_2003") ## End(Not run)
## Not run: extract_dataset(database, "Falster_2003") ## End(Not run)
Function to subset of all data associated with a particular taxon from a traits.build relational database.
extract_taxa(database, family = NULL, genus = NULL, taxon_name = NULL)
extract_taxa(database, family = NULL, genus = NULL, taxon_name = NULL)
database |
traits.build database (list object) |
family |
character string of family or families |
genus |
character string of genus or genera |
taxon_name |
character string of taxon name(s) |
extract_taxa
has been developed to extract data for specific taxa from databases built using the traits.build workflow.
Learn more at:
https://github.com/traitecoevo/traits.build &
https://github.com/traitecoevo/traits.build-book
Note to AusTraits users:
This function works with AusTraits version >= 5.0.0 (from Nov 2023 release)
For AusTraits versions <= 4.2.0 (up to Sept 2023 release) see https://github.com/traitecoevo/database for how to install old versions of the package or download a newer version of the database.
List of tibbles containing all traits.build data and metadata for the specified taxa.
Fonti Kar - [email protected]
## Not run: extract_taxa(database = austraits, family = "Proteaceae") extract_taxa(database = austraits, genus = "Acacia") ## End(Not run)
## Not run: extract_taxa(database = austraits, family = "Proteaceae") extract_taxa(database = austraits, genus = "Acacia") ## End(Not run)
Function to subset all data associated with a particular trait from a traits.build relational database.
extract_trait(database, trait_names, taxon_names)
extract_trait(database, trait_names, taxon_names)
database |
traits.build database (list object) |
trait_names |
character string of trait(s) for which data will be extracted |
taxon_names |
optional argument, specifying taxa for which data will be extracted |
extract_trait
has been developed to extract data for specific traits from databases built using the traits.build workflow.
Learn more at:
https://github.com/traitecoevo/traits.build &
https://github.com/traitecoevo/traits.build-book
Note to AusTraits users:
This function works with AusTraits version >= 5.0.0 (from Nov 2023 release)
For AusTraits versions <= 4.2.0 (up to Sept 2023 release) see https://github.com/traitecoevo/austraits for how to install old versions of the package or download a newer version of the database.
List of tibbles containing all traits.build data and metadata for the specified trait(s).
Daniel Falster - [email protected]
## Not run: extract_trait(database = austraits, trait_names = "wood_density", taxon_names = "Acacia celsa") ## End(Not run)
## Not run: extract_trait(database = austraits, trait_names = "wood_density", taxon_names = "Acacia celsa") ## End(Not run)
Create a single database output that merges together the information in all relational tables within a traits.build database. Trait measurements are still output in long format (1 row per trait value), but all measurement-related metadata (methods, location properties, context properties, contributors) are now included as additional columns in a single table.
flatten_database(database, format, vars, include_description)
flatten_database(database, format, vars, include_description)
database |
traits.build database (list object) |
format |
A parameter for the locations, contexts and data contributors tables specifying how data are packed.
All three can be formatted as a single compacted column(s) will have a human readable column ("single_column_pretty")
or using json ("single_column_json") syntax. For location properties or context properties there is also
the option to add each |
vars |
List specifying which columns or properties to include from each table. The detail is for all columns/properties to be included. |
include_description |
A logical indicating whether to include (TRUE) or omit (FALSE) the context_property descriptions; defaults to TRUE. |
A table combining information in 7 traits.build relational tables: traits, locations, contexts, methods, taxa, taxonomic_updates, and contributors
Retrieve compiled by information from metadata table
get_compiled_by_traits.build(database)
get_compiled_by_traits.build(database)
database |
traits.build database |
logical, TRUE indicating version traits table came from traits.build version > 1.0
Retrieve traits table if user passes traits.build object.
get_traits_table(database)
get_traits_table(database)
database |
traits.build database or traits table in a traits.build database |
Retrieve the latest version of AusTraits
get_version_latest(path = "data/austraits", update = TRUE)
get_version_latest(path = "data/austraits", update = TRUE)
path |
file path to where AusTraits will be downloaded |
update |
if TRUE, AusTraits versions .json will be re-downloaded |
character string of latest version
Print out AusTraits versions
get_versions(path = "data/austraits", update = TRUE)
get_versions(path = "data/austraits", update = TRUE)
path |
A file path where AusTraits was previously downloaded |
update |
Would you like the versions json be updated in case of new releases? |
A tibble containing version numbers and doi which can be used in load_austraits()
## Not run: austraits <- load_austraits(version = "3.0.2", path = "data/austraits") ## End(Not run)
## Not run: austraits <- load_austraits(version = "3.0.2", path = "data/austraits") ## End(Not run)
Function to merge metadata from the contexts table of a traits.build database into the core traits table.
join_context_properties( database, format = "single_column_pretty", vars = "all", include_description = TRUE )
join_context_properties( database, format = "single_column_pretty", vars = "all", include_description = TRUE )
database |
traits.build database (list object) |
format |
Specifies whether metadata from the contexts is output in a human readable format ("single_column_pretty"; default), with each context property added as a separate column ("many_columns") or using json syntax ("single_column_json"). |
vars |
Location properties for which data is to be appended to the traits table, defaulting to all context properties (vars = "all"). |
include_description |
A logical indicating whether to include (TRUE) or omit (FALSE) the context_property descriptions. |
the join_
functions have been developed to join relational tables for databases built using the traits.build workflow.
Learn more at:
https://github.com/traitecoevo/traits.build &
https://github.com/traitecoevo/traits.build-book
Note to AusTraits users:
This function works with AusTraits version >= 5.0.0 (from Nov 2023 release)
For AusTraits versions <= 4.2.0 (up to Sept 2023 release) see https://github.com/traitecoevo/austraits for how to install old versions of the package or download a newer version of the database.
traits.build list object, but context properties from the contexts table appended to the traits table.
## Not run: (database %>% join_context_properties( format = "many_columns", vars = "all", include_description = TRUE))$traits ## End(Not run)
## Not run: (database %>% join_context_properties( format = "many_columns", vars = "all", include_description = TRUE))$traits ## End(Not run)
Function to merge metadata from the data contributors table of a traits.build database into the core traits table.
join_contributors(database, format = "single_column_pretty", vars = "all")
join_contributors(database, format = "single_column_pretty", vars = "all")
database |
traits.build database (list object) |
format |
Specifies whether metadata from the contributors table is output in a human readable format ("single_column_pretty"; default) or using json syntax ("single_column_json"). |
vars |
Columns from the taxa table to be joined to the traits table, defaulting to all columns (vars = "all"). |
the join_
functions have been developed to join relational tables for databases built using the traits.build workflow.
Learn more at:
https://github.com/traitecoevo/traits.build &
https://github.com/traitecoevo/traits.build-book
Note to AusTraits users:
This function works with AusTraits version >= 5.0.0 (from Nov 2023 release)
For AusTraits versions <= 4.2.0 (up to Sept 2023 release) see https://github.com/traitecoevo/austraits for how to install old versions of the package or download a newer version of the database.
traits.build list object, but with additional fields (columns) for the specified variables from the data contributors table appended to the traits table.
## Not run: (database %>% join_contributors(format = "single_column_pretty", vars = c("last_name", "first_name", "ORCID")))$traits ## End(Not run)
## Not run: (database %>% join_contributors(format = "single_column_pretty", vars = c("last_name", "first_name", "ORCID")))$traits ## End(Not run)
Function to merge geographic coordinates (latitude/longitude) stored in the locations table of a traits.build database into the core traits table.
join_location_coordinates(database)
join_location_coordinates(database)
database |
traits.build database (list object) |
the join_
functions have been developed to join relational tables for databases built using the traits.build workflow.
Learn more at:
https://github.com/traitecoevo/traits.build &
https://github.com/traitecoevo/traits.build-book
Note to AusTraits users:
This function works with AusTraits version >= 5.0.0 (from Nov 2023 release)
For AusTraits versions <= 4.2.0 (up to Sept 2023 release) see https://github.com/traitecoevo/austraits for how to install old versions of the package or download a newer version of the database.
traits.build list object, but with additional fields (columns)
for latitude and longitude appended to traits
dataframe
## Not run: (database %>% join_location_coordinates)$traits ## End(Not run)
## Not run: (database %>% join_location_coordinates)$traits ## End(Not run)
Function to merge metadata from the locations table of a traits.build database into the core traits table.
join_location_properties( database, format = "single_column_pretty", vars = "all" )
join_location_properties( database, format = "single_column_pretty", vars = "all" )
database |
traits.build database (list object) |
format |
Specifies whether metadata from the locations is output in a human readable format ("single_column_pretty"; default), with each location property added as a separate column ("many_columns") or using json syntax ("single_column_json"). |
vars |
Location properties for which data is to be appended to the traits table, defaulting to all location properties (vars = "all"). |
the join_
functions have been developed to join relational tables for databases built using the traits.build workflow.
Learn more at:
https://github.com/traitecoevo/traits.build &
https://github.com/traitecoevo/traits.build-book
Note to AusTraits users:
This function works with AusTraits version >= 5.0.0 (from Nov 2023 release)
For AusTraits versions <= 4.2.0 (up to Sept 2023 release) see https://github.com/traitecoevo/austraits for how to install old versions of the package or download a newer version of the database.
traits.build list object, but location properties from the locations table appended to the traits table.
## Not run: (database %>% join_location_properties(format = "single_column_pretty", vars = "all"))$traits ## End(Not run)
## Not run: (database %>% join_location_properties(format = "single_column_pretty", vars = "all"))$traits ## End(Not run)
Function to merge metadata from the methods table of a traits.build database into the core traits table.
join_methods(database, vars = c("methods"))
join_methods(database, vars = c("methods"))
database |
traits.build database (list object) |
vars |
Columns from the taxa table to be joined to the traits table, defaulting to c("methods"). |
the join_
functions have been developed to join relational tables for databases built using the traits.build workflow.
Learn more at:
https://github.com/traitecoevo/traits.build &
https://github.com/traitecoevo/traits.build-book
Note to AusTraits users:
This function works with AusTraits version >= 5.0.0 (from Nov 2023 release)
For AusTraits versions <= 4.2.0 (up to Sept 2023 release) see https://github.com/traitecoevo/austraits for how to install old versions of the package or download a newer version of the database.
traits.build list object, but with additional fields (columns) for the specified variables from the methods table appended to the traits table.
## Not run: (database %>% join_methods)$traits ## End(Not run)
## Not run: (database %>% join_methods)$traits ## End(Not run)
Function to merge metadata from the taxa table of a traits.build database into the core traits table.
join_taxa( database, vars = c("family", "genus", "taxon_rank", "establishment_means") )
join_taxa( database, vars = c("family", "genus", "taxon_rank", "establishment_means") )
database |
traits.build database (list object) |
vars |
Columns from the taxa table to be joined to the traits table, defaulting to c("family", "genus", "taxon_rank", "establishment_means"). |
the join_
functions have been developed to join relational tables for databases built using the traits.build workflow.
Learn more at:
https://github.com/traitecoevo/traits.build &
https://github.com/traitecoevo/traits.build-book
Note to AusTraits users:
This function works with AusTraits version >= 5.0.0 (from Nov 2023 release)
For AusTraits versions <= 4.2.0 (up to Sept 2023 release) see https://github.com/traitecoevo/austraits for how to install old versions of the package or download a newer version of the database.
traits.build list object, but with additional fields (columns) for the specified variables from the taxa table appended to the traits table.
## Not run: #Append taxonomic details (database %>% join_taxa)$traits ## End(Not run)
## Not run: #Append taxonomic details (database %>% join_taxa)$traits ## End(Not run)
Function to merge metadata from the taxonomic_updates table of a traits.build database into the core traits table.
join_taxonomic_updates(database, vars = c("aligned_name"))
join_taxonomic_updates(database, vars = c("aligned_name"))
database |
traits.build database (list object) |
vars |
Columns from the taxa table to be joined to the traits table, defaulting to c("aligned_name"). |
the join_
functions have been developed to join relational tables for databases built using the traits.build workflow.
Learn more at:
https://github.com/traitecoevo/traits.build &
https://github.com/traitecoevo/traits.build-book
Note to AusTraits users:
This function works with AusTraits version >= 5.0.0 (from Nov 2023 release)
For AusTraits versions <= 4.2.0 (up to Sept 2023 release) see https://github.com/traitecoevo/austraits for how to install old versions of the package or download a newer version of the database.
traits.build list object, but with additional fields (columns) for the specified variables from the taxonomic_updates table appended to the traits table.
## Not run: #Append taxonomic update details (database %>% join_taxonomic_updates)$traits ## End(Not run)
## Not run: #Append taxonomic update details (database %>% join_taxonomic_updates)$traits ## End(Not run)
Load AusTraits database into R console
load_austraits( doi = NULL, version = NULL, path = "data/austraits", update = FALSE )
load_austraits( doi = NULL, version = NULL, path = "data/austraits", update = FALSE )
doi |
character string - doi of particular version |
version |
character string - version number of database |
path |
file path to where AusTraits will be downloaded |
update |
if TRUE, AusTraits versions .json will be re-downloaded |
a large list containing AusTraits data tables
get_versions get_version_latest
## Not run: austraits <- load_austraits(version = "3.0.2", path = "data/austraits") ## End(Not run)
## Not run: austraits <- load_austraits(version = "3.0.2", path = "data/austraits") ## End(Not run)
Look up context properties that contain a specific search term.
lookup_context_property(database, term)
lookup_context_property(database, term)
database |
traits.build database (list object) |
term |
character string for context property search term |
vector containing context properties that contains search term
## Not run: austraits %>% lookup_context_property("temperature") ## End(Not run)
## Not run: austraits %>% lookup_context_property("temperature") ## End(Not run)
Look up location properties that contain a specific search term.
lookup_location_property(database, term)
lookup_location_property(database, term)
database |
traits.build database (list object) |
term |
character string for location property search term |
vector containing location properties that contains search term
## Not run: austraits %>% lookup_location_property("soil") ## End(Not run)
## Not run: austraits %>% lookup_location_property("soil") ## End(Not run)
Look up a particular trait term
lookup_trait(database, term)
lookup_trait(database, term)
database |
traits.build database (list object) |
term |
character string for trait search term |
vector containing traits that contains search term
## Not run: austraits %>% lookup_trait("leaf") %>% extract_trait(database = austraits, .) ## End(Not run)
## Not run: austraits %>% lookup_trait("leaf") %>% extract_trait(database = austraits, .) ## End(Not run)
Plot location where trait data was collected from
plot_locations(database, feature = "trait_name", ...)
plot_locations(database, feature = "trait_name", ...)
database |
traits.build database OR traits table from a traits.build database. Note location details must be joined. See join_location_coordinates and examples |
feature |
grouping/classification categories e.g trait_name, collection_type for <= v3.0.2, basis of record for >3.0.2 |
... |
arguments passed to ggplot() |
ggplot of sites
Dony Indiarto - [email protected]
## Not run: #All traits from a given study data <- austraits %>% extract_dataset(dataset_id = "Falster_2003") %>% join_location_coordinates() data %>% plot_locations("trait_name") #Single trait data <- austraits %>% extract_trait(trait_names = c("plant_height")) %>% join_location_coordinates() data$traits %>% plot_locations("trait_name") ## End(Not run)
## Not run: #All traits from a given study data <- austraits %>% extract_dataset(dataset_id = "Falster_2003") %>% join_location_coordinates() data %>% plot_locations("trait_name") #Single trait data <- austraits %>% extract_trait(trait_names = c("plant_height")) %>% join_location_coordinates() data$traits %>% plot_locations("trait_name") ## End(Not run)
Plot location where trait data was collected from
plot_site_locations(trait_data, feature = "trait_name", ...)
plot_site_locations(trait_data, feature = "trait_name", ...)
trait_data |
traits table in a traits.build database with site details appended. See join_location_coordinates and examples |
feature |
grouping/classification categories e.g trait_name, collection_type for <= v3.0.2 |
... |
arguments passed to ggplot() |
ggplot of sites
Dony Indiarto - [email protected]
Plots distribution of trait values by a grouping variable using ggbeeswarm package
plot_trait_distribution_beeswarm( database, trait_name, y_axis_category, highlight = NA, hide_ids = FALSE )
plot_trait_distribution_beeswarm( database, trait_name, y_axis_category, highlight = NA, hide_ids = FALSE )
database |
traits.build database (list object) |
trait_name |
Name of trait to plot |
y_axis_category |
One of |
highlight |
Specify a group to highlight |
hide_ids |
Logical for whether to add a label on y_axis? |
Daniel Falster - [email protected]
## Not run: austraits %>% plot_trait_distribution_beeswarm("wood_density", "dataset_id", "Westoby_2014") ## End(Not run)
## Not run: austraits %>% plot_trait_distribution_beeswarm("wood_density", "dataset_id", "Westoby_2014") ## End(Not run)
Generic for outputting a nice summary for austraits objects
## S3 method for class 'traits.build' print(x, ...)
## S3 method for class 'traits.build' print(x, ...)
x |
traits.build database |
... |
passed to print |
nicely printed table
This function reverts the action of bind_trait_values. This function separates values that were concatenated so that studies that have multiple observations for a given trait will have seperate row for each observation.
separate_trait_values(trait_data, definitions)
separate_trait_values(trait_data, definitions)
trait_data |
The traits table in a traits.build database - see example |
definitions |
The austraits definitions data frame |
trait tibble
Daniel Falster - [email protected]
## Not run: trait_data <- austraits$traits %>% dplyr::filter(dataset_id == "Falster_2005_1") trait_data traits_bind <- bind_trait_values(trait_data) separate_trait_values(traits_bind) ## End(Not run)
## Not run: trait_data <- austraits$traits %>% dplyr::filter(dataset_id == "Falster_2005_1") trait_data traits_bind <- bind_trait_values(trait_data) separate_trait_values(traits_bind) ## End(Not run)
Summarise counts for a particular variable of interest
summarise_database(database, var)
summarise_database(database, var)
database |
traits.build database (list object) |
var |
variable you use wish to see summary of (trait_name, genus, family) |
dataframe of unique levels of variable with counts and percentage
## Not run: summarise_database(database = austraits, "trait_name") summarise_database(database = austraits, "family") ## End(Not run)
## Not run: summarise_database(database = austraits, "trait_name") summarise_database(database = austraits, "family") ## End(Not run)
trait_pivot_longer "gathers" wide format data into a "tidy" format This function converts the data into long format where observations are on different rows and the type of observation is denoted by trait name. In other words, trait_pivot_longer reverts the actions of trait_pivot_wider
trait_pivot_longer(wide_data)
trait_pivot_longer(wide_data)
wide_data |
output from trait_pivot_wider. |
If bind_trait_values
was applied prior to trait_pivot_wider
for AusTraits
<= v3.0.2, trait_pivot_longer
will return a tibble with fewer observations than the original traits table.
For AusTraits version >3.0.2, trait_pivot_longer
will return a tibble with fewer columns than that original traits table
The excluded columns include: "unit", "replicates", "measurement_remarks", "basis_of_record", "basis_of_value"
This function reverts the actions of the function austraits::trait_pivot_wider.
It begins with a derivation of a traits.build traits table, where multiple measurements that comprise a single observation are displayed on a single row,with a column for each trait. It then converts the table into long format where measurements of multiple traits that comprise a single observation are on different rows and a column specifying the trait names is added.
trait_pivot_longer
has been developed to pivot the traits table for a database build using the traits.build workflow.
Learn more at:
https://github.com/traitecoevo/traits.build &
https://github.com/traitecoevo/traits.build-book
Note to AusTraits users:
This function works with AusTraits version >= 5.0.0 (from Nov 2023 release)
For AusTraits versions <= 4.2.0 (up to Sept 2023 release) see https://github.com/traitecoevo/austraits for how to install old versions of the package or download a newer version of the database.
A tibble in long format
A tibble in long format
Daniel Falster - [email protected]
Fonti Kar - [email protected]
## Not run: data <- austraits$traits %>% filter(dataset_id == "Falster_2003") data #long format traits_wide <- trait_pivot_wider(data) traits_wide #wide format values_long <- trait_pivot_longer(traits_wide) ## End(Not run)
## Not run: data <- austraits$traits %>% filter(dataset_id == "Falster_2003") data #long format traits_wide <- trait_pivot_wider(data) traits_wide #wide format values_long <- trait_pivot_longer(traits_wide) ## End(Not run)
Function to "widen" long format data ("tidy data").
Data in a traits.build databases' traits table are organised in a long format where each trait measurement is on a different row and measurement metadata is recorded in other columns. Multiple traits may be measured as part of a single observation and this function pivots the data wider, such that each trait is its own column. Note that if two trait measurements have the same observation_id but different value types (min, mean, mode, etc.) these will be on separate rows.
The function austraits::trait_pivot_longer reverts the actions of this function.
trait_pivot_wider(database)
trait_pivot_wider(database)
database |
The traits tibble from a traits.build database |
'trait_pivot_wider“ has been developed to pivot the traits table for a database build using the traits.build workflow. Learn more at: https://github.com/traitecoevo/traits.build & https://github.com/traitecoevo/traits.build-book
Note to AusTraits users:
This function works with AusTraits version >= 5.0.0 (from Nov 2023 release)
For AusTraits versions <= 4.2.0 (up to Sept 2023 release) see https://github.com/traitecoevo/austraits for how to install old versions of the package or download a newer version of the database.
traits.build traits table in wide format
Daniel Falster - [email protected]
## Not run: data <- austraits_5.0.0_lite$traits %>% filter(dataset_id == "Falster_2003") data #long format traits_wide <- trait_pivot_wider(data) traits_wide #wide format ## End(Not run)
## Not run: data <- austraits_5.0.0_lite$traits %>% filter(dataset_id == "Falster_2003") data #long format traits_wide <- trait_pivot_wider(data) traits_wide #wide format ## End(Not run)