CompadreDB objects can be subset just like a regular data.frame, using either [ or subset(). Note, however, that the mat column will always be retained during subsetting, even if it is not included in the user's column subset.

# S4 method for CompadreDB,ANY,ANY,ANY
[(x, i, j, ..., drop = FALSE)

# S3 method for CompadreDB
subset(x, subset, select, drop = FALSE, ...)

Arguments

x

A CompadreDB object

i

row indices (see [.data.frame)

j

column indices (see [.data.frame)

...

ignored

drop

ignored

subset

logical expression indicating which rows to keep

select

expression indicating which columns to keep

Examples

# subset to the first 10 rows Compadre[1:10,]
#> A COM(P)ADRE database ('CompadreDB') object with 10 SPECIES and 10 MATRICES. #> #> # A tibble: 10 x 48 #> mat SpeciesAuthor SpeciesAccepted CommonName Genus Family Order Class #> <lis> <chr> <chr> <chr> <chr> <fct> <fct> <fct> #> 1 <Com… Setaria_incr… Setaria incras… NA Seta… Poace… Poal… Lili… #> 2 <Com… Lechea_cernua Lechea cernua NA Lech… Cista… Malv… Magn… #> 3 <Com… Actinostemon… Actinostemon c… NA Acti… Eupho… Malp… Magn… #> 4 <Com… Gaura_neomex… Gaura neomexic… NA Gaura Onagr… Myrt… Magn… #> 5 <Com… Eriogonum_lo… Eriogonum long… Buckwheat Erio… Polyg… Cary… Magn… #> 6 <Com… Platanthera_… Platanthera ho… NA Plat… Orchi… Aspa… Lili… #> 7 <Com… Succisa_prat… Succisa praten… NA Succ… Capri… Dips… Magn… #> 8 <Com… Haplopappus_… Pyrrocoma radi… NA Pyrr… Compo… Aste… Magn… #> 9 <Com… Astragalus_t… Astragalus tre… NA Astr… Legum… Faba… Magn… #> 10 <Com… Plantago_cor… Plantago coron… NA Plan… Plant… Lami… Magn… #> # … with 40 more variables: Phylum <fct>, Kingdom <fct>, OrganismType <fct>, #> # DicotMonoc <fct>, AngioGymno <fct>, Authors <chr>, Journal <chr>, #> # YearPublication <chr>, DOI.ISBN <chr>, AdditionalSource <chr>, #> # StudyDuration <dbl>, StudyStart <dbl>, StudyEnd <dbl>, #> # AnnualPeriodicity <chr>, NumberPopulations <dbl>, MatrixCriteriaSize <fct>, #> # MatrixCriteriaOntogeny <fct>, MatrixCriteriaAge <fct>, #> # MatrixPopulation <chr>, Lat <dbl>, Lon <dbl>, Altitude <dbl>, #> # Country <fct>, Continent <fct>, Ecoregion <chr>, StudiedSex <fct>, #> # MatrixComposite <fct>, MatrixTreatment <chr>, MatrixCaptivity <fct>, #> # MatrixStartYear <dbl>, MatrixStartSeason <fct>, MatrixStartMonth <chr>, #> # MatrixEndYear <dbl>, MatrixEndSeason <fct>, MatrixEndMonth <chr>, #> # MatrixSplit <fct>, MatrixFec <fct>, Observation <fct>, #> # MatrixDimension <dbl>, SurvivalIssue <dbl>
# subset to the species 'Echinacea angustifolia' subset(Compadre, SpeciesAccepted == "Echinacea angustifolia")
#> A COM(P)ADRE database ('CompadreDB') object with 1 SPECIES and 4 MATRICES. #> #> # A tibble: 4 x 48 #> mat SpeciesAuthor SpeciesAccepted CommonName Genus Family Order Class Phylum #> <lis> <chr> <chr> <chr> <chr> <fct> <fct> <fct> <fct> #> 1 <Com… Echinacea_an… Echinacea angu… Narrow-le… Echi… Compo… Aste… Magn… Magno… #> 2 <Com… Echinacea_an… Echinacea angu… Narrow-le… Echi… Compo… Aste… Magn… Magno… #> 3 <Com… Echinacea_an… Echinacea angu… Narrow-le… Echi… Compo… Aste… Magn… Magno… #> 4 <Com… Echinacea_an… Echinacea angu… Narrow-le… Echi… Compo… Aste… Magn… Magno… #> # … with 39 more variables: Kingdom <fct>, OrganismType <fct>, #> # DicotMonoc <fct>, AngioGymno <fct>, Authors <chr>, Journal <chr>, #> # YearPublication <chr>, DOI.ISBN <chr>, AdditionalSource <chr>, #> # StudyDuration <dbl>, StudyStart <dbl>, StudyEnd <dbl>, #> # AnnualPeriodicity <chr>, NumberPopulations <dbl>, MatrixCriteriaSize <fct>, #> # MatrixCriteriaOntogeny <fct>, MatrixCriteriaAge <fct>, #> # MatrixPopulation <chr>, Lat <dbl>, Lon <dbl>, Altitude <dbl>, #> # Country <fct>, Continent <fct>, Ecoregion <chr>, StudiedSex <fct>, #> # MatrixComposite <fct>, MatrixTreatment <chr>, MatrixCaptivity <fct>, #> # MatrixStartYear <dbl>, MatrixStartSeason <fct>, MatrixStartMonth <chr>, #> # MatrixEndYear <dbl>, MatrixEndSeason <fct>, MatrixEndMonth <chr>, #> # MatrixSplit <fct>, MatrixFec <fct>, Observation <fct>, #> # MatrixDimension <dbl>, SurvivalIssue <dbl>
# remove the column SurvivalIssue Compadre[,names(Compadre) != "SurvivalIssue"]
#> A COM(P)ADRE database ('CompadreDB') object with 110 SPECIES and 150 MATRICES. #> #> # A tibble: 150 x 47 #> mat SpeciesAuthor SpeciesAccepted CommonName Genus Family Order Class #> <lis> <chr> <chr> <chr> <chr> <fct> <fct> <fct> #> 1 <Com… Setaria_incr… Setaria incras… NA Seta… Poace… Poal… Lili… #> 2 <Com… Lechea_cernua Lechea cernua NA Lech… Cista… Malv… Magn… #> 3 <Com… Actinostemon… Actinostemon c… NA Acti… Eupho… Malp… Magn… #> 4 <Com… Gaura_neomex… Gaura neomexic… NA Gaura Onagr… Myrt… Magn… #> 5 <Com… Eriogonum_lo… Eriogonum long… Buckwheat Erio… Polyg… Cary… Magn… #> 6 <Com… Platanthera_… Platanthera ho… NA Plat… Orchi… Aspa… Lili… #> 7 <Com… Succisa_prat… Succisa praten… NA Succ… Capri… Dips… Magn… #> 8 <Com… Haplopappus_… Pyrrocoma radi… NA Pyrr… Compo… Aste… Magn… #> 9 <Com… Astragalus_t… Astragalus tre… NA Astr… Legum… Faba… Magn… #> 10 <Com… Plantago_cor… Plantago coron… NA Plan… Plant… Lami… Magn… #> # … with 140 more rows, and 39 more variables: Phylum <fct>, Kingdom <fct>, #> # OrganismType <fct>, DicotMonoc <fct>, AngioGymno <fct>, Authors <chr>, #> # Journal <chr>, YearPublication <chr>, DOI.ISBN <chr>, #> # AdditionalSource <chr>, StudyDuration <dbl>, StudyStart <dbl>, #> # StudyEnd <dbl>, AnnualPeriodicity <chr>, NumberPopulations <dbl>, #> # MatrixCriteriaSize <fct>, MatrixCriteriaOntogeny <fct>, #> # MatrixCriteriaAge <fct>, MatrixPopulation <chr>, Lat <dbl>, Lon <dbl>, #> # Altitude <dbl>, Country <fct>, Continent <fct>, Ecoregion <chr>, #> # StudiedSex <fct>, MatrixComposite <fct>, MatrixTreatment <chr>, #> # MatrixCaptivity <fct>, MatrixStartYear <dbl>, MatrixStartSeason <fct>, #> # MatrixStartMonth <chr>, MatrixEndYear <dbl>, MatrixEndSeason <fct>, #> # MatrixEndMonth <chr>, MatrixSplit <fct>, MatrixFec <fct>, #> # Observation <fct>, MatrixDimension <dbl>
# NOT RUN { # column selection doesn't include mat, but mat will still be returned with a # along with a warning subset(Compadre, select = c("SpeciesAccepted", "Authors")) # }