# Note that most examples here use argument
# failIfNoInternet = FALSE so that functions do
# not error out but simply return NULL if internet
# connection is not available, and thus
# fail gracefully rather than error out (required by CRAN).
# Remove this argument or set to TRUE so functions DO fail
# when internet resources (paleobiodb) is not available.
set.seed(1)
# \donttest{
#get some example occurrence and taxonomic data
data(graptPBDB)
#get the taxon tree: Linnean method
graptTreeLinnean <- makePBDBtaxonTree(
taxaDataPBDB = graptTaxaPBDB,
rankTaxon = "genus",
method = "Linnean",
failIfNoInternet = FALSE)
#get the taxon tree: parentChild method
graptTreeParentChild <- makePBDBtaxonTree(
taxaDataPBDB = graptTaxaPBDB,
rankTaxon = "genus",
method = "parentChild",
failIfNoInternet = FALSE)
if(!is.null(graptTreeParentChild) &
!is.null(graptTreeLinnean)){
# if those functions worked...
# let's plot these and compare them!
plotTaxaTreePBDB(graptTreeParentChild)
plotTaxaTreePBDB(graptTreeLinnean)
}
# pause 3 seconds so we don't spam the API
Sys.sleep(3)
####################################################
# let's try some other groups
###################################
#conodonts
conoData <- getCladeTaxaPBDB("Conodonta",
failIfNoInternet = FALSE)
if(!is.null(conoData)){
conoTree <- makePBDBtaxonTree(
taxaDataPBDB = conoData,
rankTaxon = "genus",
method = "parentChild")
# if it worked, plot it!
plotTaxaTreePBDB(conoTree)
}
# pause 3 seconds so we don't spam the API
Sys.sleep(3)
#############################
#asaphid trilobites
asaData <- getCladeTaxaPBDB("Asaphida",
failIfNoInternet = FALSE)
if(!is.null(asaData)){
asaTree <- makePBDBtaxonTree(
taxaDataPBDB = asaData,
rankTaxon = "genus",
method = "parentChild")
# if it worked, plot it!
plotTaxaTreePBDB(asaTree)
}
# pause 3 seconds so we don't spam the API
Sys.sleep(3)
###############################
#Ornithischia
ornithData <- getCladeTaxaPBDB("Ornithischia",
failIfNoInternet = FALSE)
if(!is.null(ornithData)){
ornithTree <- makePBDBtaxonTree(
taxaDataPBDB = ornithData,
rankTaxon = "genus",
method = "parentChild")
# if it worked, plot it!
plotTaxaTreePBDB(ornithTree)
# pause 3 seconds so we don't spam the API
Sys.sleep(3)
#try Linnean!
#but first... need to drop repeated taxon first: Hylaeosaurus
# actually this taxon seems to have been repaired
# as of September 2019 !
# findHylaeo <- ornithData$taxon_name == "Hylaeosaurus"
# there's actually only one accepted ID number
# HylaeoIDnum <- unique(ornithData[findHylaeo,"taxon_no"])
# HylaeoIDnum
# so, take which one has occurrences listed
# dropThis <- which((ornithData$n_occs < 1) & findHylaeo)
# ornithDataCleaned <- ornithData[-dropThis,]
ornithTree <- makePBDBtaxonTree(
ornithData,
rankTaxon = "genus",
method = "Linnean",
failIfNoInternet = FALSE)
# if it worked, plot it!
plotTaxaTreePBDB(ornithTree)
}
# pause 3 seconds so we don't spam the API
Sys.sleep(3)
#########################
# Rhynchonellida
rhynchData <- getCladeTaxaPBDB("Rhynchonellida",
failIfNoInternet = FALSE)
if(!is.null(rhynchData)){
rhynchTree <- makePBDBtaxonTree(
taxaDataPBDB = rhynchData,
rankTaxon = "genus",
method = "parentChild")
# if it worked, plot it!
plotTaxaTreePBDB(rhynchTree)
}
#some of these look pretty messy!
# }
Run the code above in your browser using DataLab