ropensci / traits

R package for accessing species trait data from multiple databases
Other
40 stars 13 forks source link

from EOL folks #119

Closed sckott closed 2 years ago

sckott commented 4 years ago

Seeing our cypher output in the trait package docs prompted us to remove the /relationships/ detritus that nobody needs. But may I offer you an alternate sample query? Potential users may find this more useful, or at least more comparable to the other data sources. Get data by predicate:

traitbank(query = "
  MATCH (p:Page)-[:trait|:inferred_trait]->(t:Trait),
  (t)-[:predicate]->(:Term { name: 'body mass'}),
  (t)-[:units_term]->(u:Term)
  RETURN p.canonical, p.page_id, t.measurement, u.name
  LIMIT 10
")$columns
#> [1] "p.canonical"   "p.page_id"     "t.measurement" "u.name"
#> 
#> $data
#>    [,1]                       [,2]      [,3]    [,4]
#> [1,] "Chrotopterus auritus"     "327367"  "73"    "g"
#> [2,] "Lerista dorsalis"         "794123"  "0.8"   "g"
#> [3,] "Gracilinanus microtarsus" "290120"  "17"    "g"
#> [4,] "Akodon montensis"         "4460331" "45.1"  "g"
#> [5,] "Nectomys squamipes"       "1179937" "287"   "g"
#> [6,] "Artibeus lituratus"       "327359"  "78.34" "g"
#> [7,] "Trinomys iheringi"        "326987"  "250"   "g"
#> [8,] "Molossus rufus"           "4439577" "43"    "g"
#> [9,] "Micronycteris megalotis"  "327387"  "10"    "g"
#> [10,] "Sturnira lilium"          "126980"  "43.6"  "g"