R Under development (unstable) (2024-07-23 r86915 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # Runs all of cheddar's tests. You must cd cheddar/tests before running > # Rscript run_all.R > library(cheddar) > > # Data for test plans > data(Benguela, BroadstoneStream, ChesapeakeBay, SkipwithPond, TL84, TL86, + YthanEstuary, pHWebs, Millstream) > > # One species. No properties. No trophic links. > c1 <- Community(nodes=data.frame(node='S'), properties=list(title='c1')) > > # One cannibalistic species > c2 <- Community(nodes=data.frame(node='S'), + trophic.links=cbind(resource='S', consumer='S'), + properties=list(title='c2')) > > # Resource-consummer > c3 <- Community(nodes=data.frame(node=c('R','C')), + trophic.links=cbind(resource='R', consumer='C'), + properties=list(title='c3')) > > # Three-species chain > c4 <- Community(nodes=data.frame(node=c('R','C','P')), + trophic.links=cbind(resource=c('R','C'), + consumer=c('C','P')), + properties=list(title='c4')) > > # IGP > c5 <- Community(nodes=data.frame(node=c('R','C','O')), + trophic.links=cbind(resource=c('R','R','C'), + consumer=c('C','O','O')), + properties=list(title='c5')) > > # Three species chain with M, N, taxonomy and trophic link properties > c6 <- Community(nodes=data.frame(node=c('R','C','P'), + M=c(1.5, 5, 100), + N=c(1000, 10, 5.5), + order=c('Order 1', 'Order 2', 'Order 2'), + family=c('Family 1', 'Family 2', 'Family 3'), + stringsAsFactors=FALSE), + trophic.links=data.frame(resource=c('R','C'), + consumer=c('C','P'), + link.evidence=c('Inferred', 'Known'), + link.strength=c(0.5, 0.2), + stringsAsFactors=FALSE), + properties=list(title='c6', M.units='g', + N.units='m^-3')) > > # A community with three nodes: > # A is a cannibal with no resources other than itself > # B consumes A > # C is a cannibal that consumes B > # D is a cannibal and has no other resources or consumers > # E has no resources or consumers > # This community is biologically silly but mathematically interesting for > # testing node status: basal, intermediate, top-level etc > c7 <- Community(properties=list(title='Test'), + nodes=data.frame(node=c('A', 'B', 'C', 'D', 'E')), + trophic.links=data.frame(resource=c('A', 'A', 'B', 'C', 'D'), + consumer=c('A', 'B', 'C', 'C', 'D'))) > > # 10 species with different categories > c8 <- Community(nodes=data.frame(node=paste('Species', 1:8), + M=c(10, 9, 5, 0.1, 0.2, 0.3, 1, 2), + N=c(10, 1, 21, 900, 500, 100, 1, 5), + category=c(rep('vert.endo', 3), + rep('', 3), + rep('vert.ecto', 2))), + properties=list(title='c7', M.units='g', N.units='m^-3')) > > AssertEqual <- function(a, b, ...) + { + res <- all.equal(a, b, ...) + if(!isTRUE(res)) + { + stop(paste(res, collapse="\n")) + } + } > > AssertTrue <- function(v) + { + AssertEqual(TRUE, v) + } > > AssertFalse <- function(v) + { + AssertEqual(FALSE, v) + } > > AssertNull <- function(v) + { + AssertEqual(NULL, v) + } > > AssertRaises <- function(ex) + { + # A function that expects an exception to be raise when ex is evalutated + res <- tryCatch(eval(ex), error=function(e) e) + if(!"error" %in% class(res)) + { + stop('Did not raise error\n') + } + } > > RunTests <- function(tests) + { + # tests should be a vector of function names + options(error=function() + { + traceback(3) + stop() + }, + stringsAsFactors=FALSE) + + if(0==length(tests)) + { + stop('No tests to run! Is the working directory cheddar/tests ?') + } + else + { + for(test in tests) + { + cat(paste('Running [', test, ']\n', sep='')) + do.call(test, args=list()) + } + } + } > > # Source all files in this dir except this one > files <- list.files(getwd(), pattern='*R$') > files <- setdiff(files, 'run.R') > junk <- sapply(file.path(getwd(), files), source) > tests <- commandArgs(trailingOnly=TRUE) > if(0==length(tests)) + { + tests <- ls(pattern=glob2rx('^Test*')) + } > > RunTests(tests) Running [TestAggregateCommunitiesBy] Running [TestAggregateCommunitiesFailures] Running [TestAggregateCommunitiesProperties] Running [TestAggregateCommunitiesSingle] c1 containing 1 nodes c2 containing 1 nodes and 1 trophic links c3 containing 2 nodes and 1 trophic links c4 containing 3 nodes and 2 trophic links c5 containing 3 nodes and 3 trophic links c6 containing 3 nodes and 2 trophic links Tuesday Lake sampled in 1984 containing 56 nodes and 269 trophic links Tuesday Lake sampled in 1986 containing 57 nodes and 241 trophic links Skipwith Pond containing 37 nodes and 381 trophic links Running [TestAggregateCommunityMeans] Running [TestBasalNodes] Running [TestBodyMassBins] Running [TestCannibals] Running [TestCommunityBasic] Running [TestCommunityCollectionFailures] Running [TestCommunityCollectionProperties] Running [TestCommunityCollectionSingle] c1 containing 1 nodes c2 containing 1 nodes and 1 trophic links c3 containing 2 nodes and 1 trophic links c4 containing 3 nodes and 2 trophic links c5 containing 3 nodes and 3 trophic links c6 containing 3 nodes and 2 trophic links Tuesday Lake sampled in 1984 containing 56 nodes and 269 trophic links Tuesday Lake sampled in 1986 containing 57 nodes and 241 trophic links Skipwith Pond containing 37 nodes and 381 trophic links Running [TestCommunityNPS] Running [TestCommunityProperties] Running [TestCommunityPropertyNames] Running [TestCommunityTrophicLinks] Running [TestConnectedNodes] Running [TestConsumersByNode] Running [TestConsumersOfNodes] Running [TestDegree] Running [TestDegreeDistribution] Running [TestDirectedConnectance] Running [TestDoLinksExist] Running [TestFractionBasalNodes] Running [TestFractionConnectedNodes] Running [TestFractionIntermediateNodes] Running [TestFractionIsolatedNodes] Running [TestFractionNonBasalNodes] Running [TestFractionNonTopLevelNodes] Running [TestFractionOfNodesByClass] Running [TestFractionTopLevelNodes] Running [TestFractions] c1 containing 1 nodes c2 containing 1 nodes and 1 trophic links c3 containing 2 nodes and 1 trophic links c4 containing 3 nodes and 2 trophic links c5 containing 3 nodes and 3 trophic links c6 containing 3 nodes and 2 trophic links Test containing 5 nodes and 5 trophic links Tuesday Lake sampled in 1984 containing 56 nodes and 269 trophic links Running [TestInDegree] Running [TestIntermediateNodes] Running [TestIsolatedNodes] Running [TestLinkageDensity] Running [TestLumpNodes] Running [TestLumpTrophicSpecies] Running [TestMinimiseSumDietGaps] c2 containing 1 nodes and 1 trophic links c3 containing 2 nodes and 1 trophic links c4 containing 3 nodes and 2 trophic links c5 containing 3 nodes and 3 trophic links c6 containing 3 nodes and 2 trophic links Tuesday Lake sampled in 1984 containing 56 nodes and 269 trophic links Tuesday Lake sampled in 1986 containing 57 nodes and 241 trophic links Ythan Estuary containing 92 nodes and 417 trophic links Skipwith Pond containing 37 nodes and 381 trophic links Broadstone Stream containing 37 nodes and 132 trophic links Benguela containing 29 nodes and 203 trophic links Running [TestNPS] Running [TestNodeNameIndices] Running [TestNodePropertyNames] c1 containing 1 nodes c2 containing 1 nodes and 1 trophic links c3 containing 2 nodes and 1 trophic links c4 containing 3 nodes and 2 trophic links c5 containing 3 nodes and 3 trophic links Running [TestNodeQuantitativeDescriptors] Running [TestNodesWithoutMOrN] Running [TestNonBasalNodes] Running [TestNonTopLevelNodes] Running [TestNormalisedTrophicGenerality] Running [TestNormalisedTrophicVulnerability] Running [TestNumberOfNodes] Running [TestNumberOfNodesByClass] Running [TestNumberOfTrophicLinks] Running [TestNvMConvexHull] Running [TestNvMLinearRegressions] Running [TestNvMSlopeAndIntercept] Running [TestNvMSlopeAndInterceptByClass] Running [TestNvMTriTrophic1] Running [TestNvMTriTrophic2] Running [TestNvMTriTrophic3] Running [TestOmnivores] Running [TestOmnivory] Running [TestOrderCommunity] Running [TestOutDegree] Running [TestPersistCollection] A collection of 10 communities A collection of 2 communities Running [TestPersistCommunity] c1 containing 1 nodes c2 containing 1 nodes and 1 trophic links c3 containing 2 nodes and 1 trophic links c4 containing 3 nodes and 2 trophic links c5 containing 3 nodes and 3 trophic links c6 containing 3 nodes and 2 trophic links Tuesday Lake sampled in 1984 containing 56 nodes and 269 trophic links Tuesday Lake sampled in 1986 containing 57 nodes and 241 trophic links Ythan Estuary containing 92 nodes and 417 trophic links Skipwith Pond containing 37 nodes and 381 trophic links Broadstone Stream containing 37 nodes and 132 trophic links Benguela containing 29 nodes and 203 trophic links Running [TestPlotWagonWheel] [1] "D:\\temp\\RtmpmCsI74\\file2d5fcaee2819" Running [TestPredationMatrix] Running [TestPredationMatrixToLinks] Running [TestQuantitativeDescriptors] Running [TestRemoveCannibalisticLinks] Running [TestRemoveIsolatedNodes] Running [TestRemoveNodes] Running [TestResolveToNodeIndices] Running [TestResolveTrophicLinksToNodeNames] Running [TestResolveTrophicLinksToRowIndices] Running [TestResourceLargerThanConsumer] Running [TestResourcesAndConsumersByNode] Running [TestResourcesByNode] Running [TestResourcesOfNodes] Running [TestShortestPathLengths] Running [TestSimplePlotFunctions] PlotAuppervAlower [1] "D:\\temp\\RtmpmCsI74\\file2d5fc75d06037" PlotBCvBR [1] "D:\\temp\\RtmpmCsI74\\file2d5fc1ccf504a" PlotBDistribution [1] "D:\\temp\\RtmpmCsI74\\file2d5fc24042087" PlotBPyramid [1] "D:\\temp\\RtmpmCsI74\\file2d5fc3d5f362" PlotBRvBC [1] "D:\\temp\\RtmpmCsI74\\file2d5fc20a36c32" PlotBSpectrum [1] "D:\\temp\\RtmpmCsI74\\file2d5fcc041fc0" PlotBvM [1] "D:\\temp\\RtmpmCsI74\\file2d5fc5ae216aa" PlotBvRankB [1] "D:\\temp\\RtmpmCsI74\\file2d5fc6b3b277c" PlotCircularWeb [1] "D:\\temp\\RtmpmCsI74\\file2d5fcfc75eec" PlotDegreeDistribution [1] "D:\\temp\\RtmpmCsI74\\file2d5fc7bdd5e9d" PlotMCvMR [1] "D:\\temp\\RtmpmCsI74\\file2d5fc3f8f1f55" PlotMDistribution [1] "D:\\temp\\RtmpmCsI74\\file2d5fc5da2198d" PlotMRvMC [1] "D:\\temp\\RtmpmCsI74\\file2d5fc124d2fb8" PlotMvB [1] "D:\\temp\\RtmpmCsI74\\file2d5fc58e34fca" PlotMvN [1] "D:\\temp\\RtmpmCsI74\\file2d5fc6fd32daf" PlotMvRankM [1] "D:\\temp\\RtmpmCsI74\\file2d5fc55a446dd" PlotNCvNR [1] "D:\\temp\\RtmpmCsI74\\file2d5fc4ed51f2e" PlotNDistribution [1] "D:\\temp\\RtmpmCsI74\\file2d5fc43d16990" PlotNPyramid [1] "D:\\temp\\RtmpmCsI74\\file2d5fc7f4c235e" PlotNRvNC [1] "D:\\temp\\RtmpmCsI74\\file2d5fc58c81f5c" PlotNSpectrum [1] "D:\\temp\\RtmpmCsI74\\file2d5fc741925a8" PlotNvM [1] "D:\\temp\\RtmpmCsI74\\file2d5fc46183821" PlotNvRankN [1] "D:\\temp\\RtmpmCsI74\\file2d5fc4feb470f" PlotPredationMatrix [1] "D:\\temp\\RtmpmCsI74\\file2d5fc4d88401a" PlotWebByLevel [1] "D:\\temp\\RtmpmCsI74\\file2d5fc396271c4" Running [TestSiteBySpeciesMatrix] Running [TestStripWhiteSpace] Running [TestSumBiomassByClass] Running [TestSumDietGap] Running [TestSumNByClass] Running [TestTLPS] Running [TestThreeNodeChains] c1 containing 1 nodes c2 containing 1 nodes and 1 trophic links c3 containing 2 nodes and 1 trophic links c4 containing 3 nodes and 2 trophic links c5 containing 3 nodes and 3 trophic links c6 containing 3 nodes and 2 trophic links Test containing 5 nodes and 5 trophic links Tuesday Lake sampled in 1984 containing 56 nodes and 269 trophic links Tuesday Lake sampled in 1986 containing 57 nodes and 241 trophic links Ythan Estuary containing 92 nodes and 417 trophic links Skipwith Pond containing 37 nodes and 381 trophic links Running [TestTopLevelNodes] Running [TestTrophicChains] c1 containing 1 nodes c2 containing 1 nodes and 1 trophic links c3 containing 2 nodes and 1 trophic links c4 containing 3 nodes and 2 trophic links c5 containing 3 nodes and 3 trophic links c6 containing 3 nodes and 2 trophic links Test containing 5 nodes and 5 trophic links test1 containing 3 nodes and 3 trophic links test2 containing 3 nodes and 4 trophic links test2 containing 3 nodes and 3 trophic links Tuesday Lake sampled in 1984 containing 56 nodes and 269 trophic links Tuesday Lake sampled in 1986 containing 57 nodes and 241 trophic links Ythan Estuary containing 92 nodes and 417 trophic links Broadstone Stream containing 37 nodes and 132 trophic links Running [TestTrophicChainsStats] Tuesday Lake sampled in 1984 containing 56 nodes and 269 trophic links Tuesday Lake sampled in 1986 containing 57 nodes and 241 trophic links Ythan Estuary containing 92 nodes and 417 trophic links Skipwith Pond containing 37 nodes and 381 trophic links Broadstone Stream containing 37 nodes and 132 trophic links Running [TestTrophicChainsStatsOverflow] Unexpected error in trophic_chains_size [Too many chains to count without overflow] Running [TestTrophicHeight] Running [TestTrophicLevel] Running [TestTrophicLinkPropertyNames] c2 containing 1 nodes and 1 trophic links c3 containing 2 nodes and 1 trophic links c4 containing 3 nodes and 2 trophic links c5 containing 3 nodes and 3 trophic links Running [TestTrophicLinksForNodes] Running [TestTrophicSimilarity] Running [TestTrophicSpecies] > > proc.time() user system elapsed 19.68 0.62 20.48