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

Value

No return value, called for side effects

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 × 49
#>    mat        SpeciesAuthor  SpeciesAccepted CommonName Genus Family Order Class
#>    <list>     <chr>          <chr>           <chr>      <chr> <fct>  <fct> <fct>
#>  1 <CompdrMt> Setaria_incra… Setaria incras… NA         Seta… Poace… Poal… Lili…
#>  2 <CompdrMt> Lechea_cernua  Lechea cernua   NA         Lech… Cista… Malv… Magn…
#>  3 <CompdrMt> Actinostemon_… Actinostemon c… NA         Acti… Eupho… Malp… Magn…
#>  4 <CompdrMt> Gaura_neomexi… Gaura neomexic… NA         Gaura Onagr… Myrt… Magn…
#>  5 <CompdrMt> Eriogonum_lon… Eriogonum long… Buckwheat  Erio… Polyg… Cary… Magn…
#>  6 <CompdrMt> Platanthera_h… Platanthera ho… NA         Plat… Orchi… Aspa… Lili…
#>  7 <CompdrMt> Succisa_prate… Succisa praten… NA         Succ… Capri… Dips… Magn…
#>  8 <CompdrMt> Haplopappus_r… Pyrrocoma radi… NA         Pyrr… Compo… Aste… Magn…
#>  9 <CompdrMt> Astragalus_tr… Astragalus tre… NA         Astr… Legum… Faba… Magn…
#> 10 <CompdrMt> Plantago_coro… Plantago coron… NA         Plan… Plant… Lami… Magn…
#> # ℹ 41 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>,
#> #   ProjectionInterval <chr>, NumberPopulations <dbl>,
#> #   MatrixCriteriaSize <fct>, MatrixCriteriaOntogeny <fct>,
#> #   MatrixCriteriaAge <fct>, MatrixPopulation <chr>, Lat <dbl>, Lon <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 × 49
#>   mat        SpeciesAuthor   SpeciesAccepted CommonName Genus Family Order Class
#>   <list>     <chr>           <chr>           <chr>      <chr> <fct>  <fct> <fct>
#> 1 <CompdrMt> Echinacea_angu… Echinacea angu… Narrow-le… Echi… Compo… Aste… Magn…
#> 2 <CompdrMt> Echinacea_angu… Echinacea angu… Narrow-le… Echi… Compo… Aste… Magn…
#> 3 <CompdrMt> Echinacea_angu… Echinacea angu… Narrow-le… Echi… Compo… Aste… Magn…
#> 4 <CompdrMt> Echinacea_angu… Echinacea angu… Narrow-le… Echi… Compo… Aste… Magn…
#> # ℹ 41 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>,
#> #   ProjectionInterval <chr>, NumberPopulations <dbl>,
#> #   MatrixCriteriaSize <fct>, MatrixCriteriaOntogeny <fct>,
#> #   MatrixCriteriaAge <fct>, MatrixPopulation <chr>, Lat <dbl>, Lon <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 × 48
#>    mat        SpeciesAuthor  SpeciesAccepted CommonName Genus Family Order Class
#>    <list>     <chr>          <chr>           <chr>      <chr> <fct>  <fct> <fct>
#>  1 <CompdrMt> Setaria_incra… Setaria incras… NA         Seta… Poace… Poal… Lili…
#>  2 <CompdrMt> Lechea_cernua  Lechea cernua   NA         Lech… Cista… Malv… Magn…
#>  3 <CompdrMt> Actinostemon_… Actinostemon c… NA         Acti… Eupho… Malp… Magn…
#>  4 <CompdrMt> Gaura_neomexi… Gaura neomexic… NA         Gaura Onagr… Myrt… Magn…
#>  5 <CompdrMt> Eriogonum_lon… Eriogonum long… Buckwheat  Erio… Polyg… Cary… Magn…
#>  6 <CompdrMt> Platanthera_h… Platanthera ho… NA         Plat… Orchi… Aspa… Lili…
#>  7 <CompdrMt> Succisa_prate… Succisa praten… NA         Succ… Capri… Dips… Magn…
#>  8 <CompdrMt> Haplopappus_r… Pyrrocoma radi… NA         Pyrr… Compo… Aste… Magn…
#>  9 <CompdrMt> Astragalus_tr… Astragalus tre… NA         Astr… Legum… Faba… Magn…
#> 10 <CompdrMt> Plantago_coro… Plantago coron… NA         Plan… Plant… Lami… Magn…
#> # ℹ 140 more rows
#> # ℹ 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>,
#> #   ProjectionInterval <chr>, NumberPopulations <dbl>,
#> #   MatrixCriteriaSize <fct>, MatrixCriteriaOntogeny <fct>, …

if (FALSE) {
# column selection doesn't include mat, but mat will still be returned with a
#  along with a warning
subset(Compadre, select = c("SpeciesAccepted", "Authors"))
}