aggregateByGenet {plantTracker}R Documentation

aggregateByGenet

Description

This function aggregates a data.frame by unique trackIDs so that each row represents a genet (unique genetic individual) in a given year.

Usage

aggregateByGenet(
  dat,
  site = "Site",
  quad = "Quad",
  species = "Species",
  year = "Year",
  trackID = "trackID",
  ...
)

Arguments

dat

An sf data.frame. Typically this is a data.frame that has been returned from the trackSpp() function, although 'dat' can be any sf data.frame of organism demographic data in which each genet is given unique identifying value (what we call here a 'trackID'). If 'dat' already only has one row for each unique trackID in each unique year (i.e. there are no vegetative individuals–no ramets), then the output of aggregateByGenet() will have the same number of rows as 'dat'. If 'dat' has multiple rows (each of which is a ramet) for the same trackID in the same year, then the output of aggregateByGenet() will have fewer rows than the input 'dat' data.frame. 'dat' MUST have columns called 'basalArea_genet', 'age', 'recruit', 'survives_tplus1', 'nearEdge', and 'size_tplus1', although they can be populated with NAs. The trackSpp() function adds these columns, so if you have made no changes to the data.frame that was returned from trackSpp(), then your data.frame should have these columns already.

site

A character string giving the name of the column in 'dat' that contains the values for site. The default is "Site".

quad

A character string giving the name of the column in 'dat' that contains the values for quadrat. The default is "Quad".

species

A character string giving the name of the column in 'dat' that contains the values for species. The default is "Species".

year

A character string giving the name of the column in 'dat' that contains the values for year. The default is "Year".

trackID

A character string giving the name of the column in 'dat' that contains the values for the unique identifier, or trackID. The default is "trackID".

...

Other arguments passed on to methods. Not currently used.

Details

This function is a plantTracker-specific, user-friendly wrapper for the 'aggregate' function. This function was designed for use within the trackSpp function, but can be also called independently by the user. The function is designed to take a data.frame of the same format that is returned by trackSpp(), but it can be used to aggregate any dataset by genet (or some other unique identifier), as long as there is a column that identifies genet (or unique identifier) identity for each observation.

Value

An sf data.frame that has been aggregated by genet so that each row represents one unique genetic individual in one year. This data.frame has columns containing data for site, quadrat, species, year, and trackID, as well as columns called 'basalArea_genet', 'age', 'recruit', 'survives_tplus1', 'nearEdge', and 'size_tplus1'. This data.frame will most likely be shorter than the input 'dat', because a genet that was previously broken into multiple rows representing each ramet in each year will now have only one row in each year.

See Also

This function is called inside the trackSpp() function.

Examples

dat <- grasslandData[grasslandData$Site == c("AZ") &
 grasslandData$Species %in% c("Bouteloua rothrockii", "Calliandra eriophylla" ),]
names(dat)[1] <- "speciesName"
inv <- grasslandInventory[unique(dat$Quad)]
outDat <- trackSpp(dat = dat,
 inv = inv,
 dorm = 1,
 buff = .05,
 buffGenet = 0.005,
 clonal = data.frame("Species" = unique(dat$speciesName),
 "clonal" = c(TRUE,FALSE)),
 species = "speciesName",
 aggByGenet = FALSE
 )

aggregateByGenet(dat = outDat,
species = 'speciesName')

[Package plantTracker version 1.1.0 Index]