Learn R Programming

taxotools (version 0.0.139)

compact_ids: compact id numbers

Description

Compacting and converting the id values to numeric if required to make sure dependent functions work well

Usage

compact_ids(dat, id = "id", accid = "accid", startid = 1, verbose = TRUE)

Value

returns data frame

Arguments

dat

taxonomic list in a data frame with id and accid columns

id

column name for 'id'. Default 'id'

accid

column name for 'accid'. Default 'accid'

startid

starting id number for the list. Default 1

verbose

verbose output on the console

Details

Helper function to make sure values for ids are in right format and are compact

See Also

Other List functions: DwC2taxo(), cast_cs_field(), get_synonyms(), match_lists(), melt_cs_field(), merge_lists(), syn2taxo(), synonymize_subspecies(), taxo2DwC(), taxo2doc(), taxo2syn(), wiki2taxo()

Examples

Run this code
# \donttest{
mylist <- data.frame("id" = c("1","2","3","4","5"),
                     "canonical" = c("Hypochlorosis ancharia",
                                     "Pseudonotis humboldti",
                                     "Myrina ancharia",
                                     "Hypochlorosis ancharia obiana",
                                     "Hypochlorosis lorquinii"),
                     "family" = c("Lycaenidae", "Lycaenidae", 
                                  "Lycaenidae", "Lycaenidae",
                                  "Lycaenidae"),
                     "accid" = c("0","1","1","0","0"),
                     "source" = c("itis","wiki","wiki","itis",
                                  "itis"),
                     stringsAsFactors = FALSE)

mylist_c <- compact_ids(mylist)

mylist_c <- compact_ids(mylist,startid=1001)

mylist <- data.frame("id" = c(11,12,13,14,15),
                     "canonical" = c("Hypochlorosis ancharia",
                                     "Pseudonotis humboldti",
                                     "Myrina ancharia",
                                     "Hypochlorosis ancharia obiana",
                                     "Hypochlorosis lorquinii"),
                     "family" = c("Lycaenidae", "Lycaenidae", 
                                  "Lycaenidae", "Lycaenidae",
                                  "Lycaenidae"),
                     "accid" = c(0,11,11,0,0),
                     "source" = c("itis","wiki","wiki","itis",
                                  "itis"),
                     stringsAsFactors = FALSE)
                     
mylist_c <- compact_ids(mylist)
# }

Run the code above in your browser using DataLab