Skip to contents

Turn the traits element or the entire list returned by [pp_traits()] into a data.frame.

Usage

ppo_traits_flatten(x, flatten_all = FALSE)

Arguments

x

(object) A list or data.frame as returned from link(rppo)[ppo_traits]

flatten_all

(logical) Should the output list be melted in a data.frame. Default : FALSE

Value

A list for each event id containing a list with the following elements:

  • `metadata`: A data frame containing metadata

  • `taxonomy`: A data.frame containing the taxonomy

  • `traits`: A melted data.frame containing the traits value

IF flatten_all is TRUE, the list is flatten to a data.frame

Examples

r1 <- ppo_data(genus = "Quercus", termID = 'obo:PPO_0002313', limit = 10, timeLimit = 4)
#> sending request for data ...
#> https://biscicol.org/api/v3/download/_search?q=+genus:Quercus++AND+++termID:"obo:PPO_0002313"&limit=10
r1_traits <- ppo_traits(r1, sorted = FALSE, flatten_traits = FALSE)
#> Warning: cannot open URL 'https://www.usanpn.org:443/npn_portal/observations/getObservationById.json?request_src=PPO&observation_id=2484719': HTTP status was '404 Not Found'
#> Error in open.connection(con, "rb"): cannot open the connection to 'http://www.usanpn.org/npn_portal/observations/getObservationById.json?request_src=PPO&observation_id=2484719'
r1_traits <- ppo_traits_flatten(r1_traits, flatten_all = TRUE)
#> Error: object 'r1_traits' not found