ropensci / taxa

taxonomic classes for R
https://docs.ropensci.org/taxa
Other
48 stars 12 forks source link

Add taxon ids for names to table column output in `get_data` #48

Closed zachary-foster closed 7 years ago

zachary-foster commented 7 years ago

get_data returns this:

> ex_taxmap$get_data()
$taxon_names
             1              2              3              4              5              6              7              8              9 
    "Mammalia"      "Plantae"      "Felidae" "Notoryctidae"    "Hominidae"   "Solanaceae"     "Panthera"        "Felis"   "Notoryctes" 
            10             11             12             13             14             15             16             17 
        "homo"      "Solanum"       "tigris"        "catus"     "typhlops"      "sapiens" "lycopersicum"    "tuberosum" 

$taxon_ids
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15" "16" "17"

$taxon_indexes
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17

$n_supertaxa
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 
 0  0  1  1  1  1  2  2  2  2  2  3  3  3  3  3  3 

$n_subtaxa
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 
11  4  4  2  2  3  1  1  1  1  2  0  0  0  0  0  0 

$n_subtaxa_1
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 
 3  1  2  1  1  1  1  1  1  1  2  0  0  0  0  0  0 

$name
[1] tiger  cat    mole   human  tomato potato
Levels: cat human mole potato tiger tomato

$n_legs
[1] 4 4 4 2 0 0

$dangerous
[1]  TRUE FALSE FALSE  TRUE FALSE FALSE

$phylopic_ids
                                    12                                     13                                     14 
"e148eabb-f138-43c6-b1e4-5cda2180485a" "12899ba0-9923-4feb-a7f9-758c3c7d5e13" "11b783d5-af1c-4f4e-8ab5-a51470652b47" 
                                    15                                     16                                     17 
"9fae30cd-fb59-4a81-a39c-e1826a35f612" "b6400f39-345a-4711-ab4f-92fd4e22cb1a" "63604565-0406-460b-8cb8-1abe954b3f3a" 

$foods
$foods$`12`
[1] "mammals" "birds"  

$foods$`13`
[1] "cat food" "mice"    

$foods$`14`
[1] "insects"

$foods$`15`
[1] "Most things, but especially anything rare or expensive"

$foods$`16`
[1] "light" "dirt" 

$foods$`17`
[1] "light" "dirt" 

$reaction
[1] "Watch out! That tiger might attack!" "No worries; its just a cat."         "No worries; its just a mole."       
[4] "Watch out! That human might attack!" "No worries; its just a tomato."      "No worries; its just a potato." 

Note how entries like "dangerous" that came from tables in ex_taxmap$data are not named by taxon id. Not all tables have a "taxon_id" column, but if it is there, then they should be named.

zachary-foster commented 7 years ago

I thin I have it working:

> ex_taxmap$get_data()
$taxon_names
             1              2              3              4              5              6              7              8              9 
    "Mammalia"      "Plantae"      "Felidae" "Notoryctidae"    "Hominidae"   "Solanaceae"     "Panthera"        "Felis"   "Notoryctes" 
            10             11             12             13             14             15             16             17 
        "homo"      "Solanum"       "tigris"        "catus"     "typhlops"      "sapiens" "lycopersicum"    "tuberosum" 

$taxon_ids
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15" "16" "17"

$taxon_indexes
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 

$n_supertaxa
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 
 0  0  1  1  1  1  2  2  2  2  2  3  3  3  3  3  3 

$n_subtaxa
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 
11  4  4  2  2  3  1  1  1  1  2  0  0  0  0  0  0 

$n_subtaxa_1
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 
 3  1  2  1  1  1  1  1  1  1  2  0  0  0  0  0  0 

$taxon_ranks
        1         2         3         4         5         6         7         8         9        10        11        12        13 
  "class" "kingdom"  "family"  "family"  "family"  "family"   "genus"   "genus"   "genus"   "genus"   "genus" "species" "species" 
       14        15        16        17 
"species" "species" "species" "species" 

$is_root
    1     2     3     4     5     6     7     8     9    10    11    12    13    14    15    16    17 
 TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 

$is_stem
    1     2     3     4     5     6     7     8     9    10    11    12    13    14    15    16    17 
 TRUE  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE 

$is_branch
    1     2     3     4     5     6     7     8     9    10    11    12    13    14    15    16    17 
FALSE FALSE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 

$is_leaf
    1     2     3     4     5     6     7     8     9    10    11    12    13    14    15    16    17 
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE 

$name
    12     13     14     15     16     17 
 tiger    cat   mole  human tomato potato 
Levels: cat human mole potato tiger tomato

$n_legs
12 13 14 15 16 17 
 4  4  4  2  0  0 

$dangerous
   12    13    14    15    16    17 
 TRUE FALSE FALSE  TRUE FALSE FALSE 

$phylopic_ids
                                    12                                     13                                     14 
"e148eabb-f138-43c6-b1e4-5cda2180485a" "12899ba0-9923-4feb-a7f9-758c3c7d5e13" "11b783d5-af1c-4f4e-8ab5-a51470652b47" 
                                    15                                     16                                     17 
"9fae30cd-fb59-4a81-a39c-e1826a35f612" "b6400f39-345a-4711-ab4f-92fd4e22cb1a" "63604565-0406-460b-8cb8-1abe954b3f3a" 

$foods
$foods$`12`
[1] "mammals" "birds"  

$foods$`13`
[1] "cat food" "mice"    

$foods$`14`
[1] "insects"

$foods$`15`
[1] "Most things, but especially anything rare or expensive"

$foods$`16`
[1] "light" "dirt" 

$foods$`17`
[1] "light" "dirt" 

$reaction
[1] "Watch out! That tiger might attack!" "No worries; its just a cat."         "No worries; its just a mole."       
[4] "Watch out! That human might attack!" "No worries; its just a tomato."      "No worries; its just a potato."