Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/aggregateByGenet.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#'
#' @param 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 plant demographic data in which each genet is given unique
#' 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()]
Expand Down
24 changes: 15 additions & 9 deletions R/assign.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
#' Tracks genets through time
#'
#' @description This function tracks individual plants through time, but only
#' @description This function tracks individual organisms through time, but only
#' for one species in one quadrat. It is designed for use within the
#' \code{\link{trackSpp}} function, and is not intended for use on its own.
#'
#' @details see \code{\link{trackSpp}} for details of arguments and usage.
#'
#' @param dat An sf data.frame of the same format as
#' \code{\link{grasslandData}}. 'dat' must contain data for only one species in
#' one quadrat. It must have columns that contain a unique
#' identification for each research site (default name is "Site"), species name
#' (default name is "Species"), quadrat identifier (default name is "Quad"),
#' year of data collection (default name is "Year") and an s.f 'geometry' column
#' that contains a polygon or multipolygon data type for each
#' individual observation.
#' one quadrat. It must have columns that contain...
#' * a unique identification for each research site in character format
#' with no NAs (the default column name is "Site")
#' * species name in character format with no NAs (the default column
#' name is "Species")
#' * unique quadrat identifier in character format with no NAs (the default
#' column name is "Quad")
#' * year of data collection in integer format with no NAs (the
#' default column name is "Year")
#' * an s.f 'geometry' column that contains a= polygon or multipolygon data type
#' for each individual observation (the default column name is "geometry")
#'
#' This function will add columns called "basalArea_ramet", "trackID",
#' "age", "size_tplus1", "recruit" and "survives_tplus1", so 'dat' should not
#' contain columns with these names.
Expand Down Expand Up @@ -872,8 +878,8 @@
}

## check: for individuals that are dormant (and only if dorm = 1),
# then a really tiny plant can't become a really big plant (i.e. a
# plant that is really tiny probably can't go dormant)
# then a really tiny organism can't become a really big organism
# (i.e. an organism that is really tiny probably can't go dormant)
if (dorm >= 1 & ## if the dorm argument is > 0...
length(unique(round(dat$basalArea_ramet, 5))) > 3 ## if the
# sizes are not all the same (i.e. if the species is measured
Expand Down
17 changes: 11 additions & 6 deletions R/checkDat.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@
#' plantTracker functions.
#'
#' @param dat An sf data.frame of the same format as
#' \code{\link{grasslandData}}. It must have columns that contains a unique
#' identification for each research site (default name is "Site"), species name
#' (default name is "Species"), quadrat identifier (default name is "Quad"),
#' year of data collection (default name is "Year") and an s.f 'geometry' column
#' that contains a polygon or multipolygon data type for each
#' individual observation.
#' \code{\link{grasslandData}}. It must have columns that contain...
#' * a unique identification for each research site in character format
#' with no NAs (the default column name is "Site")
#' * species name in character format with no NAs (the default column
#' name is "Species")
#' * unique quadrat identifier in character format with no NAs (the default
#' column name is "Quad")
#' * year of data collection in integer format with no NAs (the
#' default column name is "Year")
#' * an s.f 'geometry' column that contains a polygon or multipolygon data type
#' for each individual observation (the default column name is "geometry")
#' @param inv The name of each element of the list is a
#' quadrat name in 'dat', and the contents of that list element is a numeric
#' vector of all of the years in which that quadrat (or other unique spatial
Expand Down
19 changes: 13 additions & 6 deletions R/drawQuadMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@
#' (either a genet or a ramet) in a unique site/quadrat/year combination. It is
#' recommended that you only input data for one quadrat at a time. A data.frame
#' returned by \code{\link{trackSpp}} can be put into this function after being
#' subset by quadrat. 'dat' must have columns that contain a unique
#' identification for each research site (default name is "Site"), species name
#' (default name is "Species"), quadrat identifier (default name is "Quad"),
#' year of data collection (default name is "Year"), a unique identifier for
#' each genet (default name is 'trackID') and an s.f 'geometry' column that
#' contains a polygon or multipolygon data type for each individual observation.
#' subset by quadrat. 'dat' must have columns that contain...
#' * a unique identification for each research site in character format
#' with no NAs (the default column name is "Site")
#' * species name in character format with no NAs (the default column
#' name is "Species")
#' * unique quadrat identifier in character format with no NAs (the default
#' column name is "Quad")
#' * year of data collection in integer format with no NAs (the
#' default column name is "Year")
#' * a unique identifier for each genet in character format with no NAs (the
#' default column name is "trackID")
#' * an s.f 'geometry' column that contains a polygon or multipolygon data type
#' for each individual observation (the default column name is "geometry")
#' @param type A character argument indicating how the plots returned by
#' `drawQuadMap()` will be color coded. If `type = "bySpecies"`, then
#' observations are color-coded by species. If `type = "bytrackID"`, then
Expand Down
29 changes: 19 additions & 10 deletions R/getBasalAreas.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@
#' data.frame returned by \code{\link{trackSpp}} can be put directly into this
#' function. However, it is not necessary for 'dat' to have demographic data or
#' unique identifiers (i.e. 'trackIDs') assigned. 'dat' must have columns that
#' contain a unique identification for each research site (default name is
#' "Site"), species name (default name is "Species"), quadrat identifier
#' (default name is "Quad"), year of data collection (default name is "Year"),
#' and an s.f 'geometry' column that contains a polygon or multipolygon data
#' type for each individual observation. This function should only be used if
#' contain...
#' * a unique identification for each research site in character format
#' with no NAs (the default column name is "Site")
#' * species name in character format with no NAs (the default column
#' name is "Species")
#' * unique quadrat identifier in character format with no NAs (the default
#' column name is "Quad")
#' * year of data collection in integer format with no NAs (the
#' default column name is "Year")
#' * an s.f 'geometry' column that contains a polygon or multipolygon data type
#' for each individual observation (the default column name is "geometry")
#'
#' This function should only be used if
#' the individuals in 'dat' were mapped as polygons that are representative of
#' their actual basal area, i.e. were not mapped as points.
#' @param inv The name of each element of the list is a
Expand Down Expand Up @@ -61,12 +69,12 @@
#' four of these columns. The column "absolute_basalArea" has the area of the
#' quadrat that is occupied by a species in a given unique site/quadrat/year
#' combination. This is in the same units as the area in 'dat'.
#' "quad_basalArea" gives the combined basal area of all plants in a given
#' "quad_basalArea" gives the combined basal area of all organisms in a given
#' site/quadrat/year. "percent_basalArea" gives the percentage of occupied basal
#' area within a quadrat that is occupied by each species in a given
#' site/quadrat/year. For example, species A has a basal area of 22 cm^2 in
#' quadrat 1 in 2005 ("absolute_basalArea = 22). In 2005, there are 50 cm^2 of
#' quadrat 1 that are occupied by plants ("quad_basalArea" = 55). 44% of the
#' quadrat 1 that are occupied by organisms ("quad_basalArea" = 55). 44% of the
#' occupied basal area in quadrat 1 in 2005 is occupied by species A
#' ("percent_basalArea" = 44). There may be an 'NA' in the "percent_basalArea"
#' column if the "quad_basalArea" for that species and year is 0.
Expand Down Expand Up @@ -171,13 +179,14 @@ getBasalAreas <- function(dat,
by.y = c("Site","Quad","Species", "yearInv"),
all = TRUE)
## put 0s where they are appropriate (i.e. in years when quad was sampled but
# no plants of that species were present)
# no organisms of that species were present)
tempArea[is.na(tempArea$absolute_basalArea),"absolute_basalArea"] <- 0
datArea <- tempArea

## calculate the percent of total basal area in that year
# (the basal area of species A / basal area of quadrat occupied by any plants)
## get the total plant area by site/quad/year
# (the basal area of species A / basal area of quadrat occupied by
# any organisms)
## get the total organism area by site/quad/year
quadBasalArea <- aggregate(x = datArea$absolute_basalArea,
by = list(
Year = datArea$Year,
Expand Down
32 changes: 18 additions & 14 deletions R/getLambda.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#' greater than 1 indicates a population is growing, while a value less than 1
#' indicates population decline. Lambda is 'infinity' when the basal area or
#' number of individuals in year t is 0, and is NA when basal area or number of
#' individuals in year t is zero (i.e. when there are no plants present in year
#' t). Note that a lambda value is calculated between of the years when a
#' individuals in year t is zero (i.e. when there are no organims present in
#' year =t). Note that a lambda value is calculated between of the years when a
#' quadrat was sampled, even if there is a gap in sampling. For example, a
#' quadrat is sampled in 1998, 1999, 2001, and 2002 (but skipped in 2000). A
#' lambda value will be calculated for 1998-1999 and 2001-2002, which is a
Expand All @@ -22,13 +22,21 @@
#' @param dat An sf data.frame in which each row represents a unique polygon
#' (either a genet or a ramet) in a unique site/quadrat/year combination. A
#' data.frame returned by \code{\link{trackSpp}} can be put directly into this
#' function. However, it is not necessary for 'dat' to have demographic data or
#' unique identifiers (i.e. 'trackIDs') assigned. 'dat' must have columns that
#' contain a unique identification for each research site (default name is
#' "Site"), species name (default name is "Species"), quadrat identifier
#' (default name is "Quad"), year of data collection (default name is "Year"),
#' and an s.f 'geometry' column that contains a polygon or multipolygon data
#' type for each individual observation.
#' function. However, it is not strictly necessary for 'dat' to have demographic
#' data or unique identifiers (i.e. 'trackIDs') assigned. If there are not
#' trackIDs assigned for each individual, then the function assumes that each
#' row of data repesents one genetic individual.'dat' *must* have columns that
#' contain...
#' * a unique identification for each research site in character format
#' with no NAs (the default column name is "Site")
#' * species name in character format with no NAs (the default column
#' name is "Species")
#' * unique quadrat identifier in character format with no NAs (the default
#' column name is "Quad")
#' * year of data collection in integer format with no NAs (the
#' default column name is "Year")
#' * an s.f 'geometry' column that contains a polygon or multipolygon data type
#' for each individual observation (the default column name is "geometry")
#' @param inv The name of each element of the list is a
#' quadrat name in 'dat', and the contents of that list element is a numeric
#' vector of all of the years in which that quadrat (or other unique spatial
Expand Down Expand Up @@ -284,7 +292,7 @@ getLambda <- function(dat,
## get the 'Year_tplus1' value (the next sequential year of sampling,
# NOT necessarily the next sequential year)
datSpp$Year_tplus1 <- c(datSpp$Year_t[2:length(datSpp$Year_t)], NA)
## get the 'Yabsolute_basalArea_tplus1' value (the next sequential
## get the 'absolute_basalArea_tplus1' value (the next sequential
# year of sampling, NOT necessarily the next sequential year)
datSpp$absolute_basalArea_tplus1 <-
c(datSpp$absolute_basalArea_t[2:length(
Expand All @@ -311,10 +319,6 @@ getLambda <- function(dat,
# (have an NA for year_tplus1)
datLambda <- datLambda[is.na(datLambda$Year_tplus1) == FALSE,]

## change the values for lambda when area_t and area_tplus1 are both zero
# from NaN to NA
datLambda[is.nan(datLambda$lambda) == TRUE,"lambda"] <- NA

## rename the columns to the user-defined columns
## from above, user-provided names are stored in 'usrNames'
defaultNames <- c("Species", "Site", "Quad")
Expand Down
19 changes: 13 additions & 6 deletions R/getNeighbors.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@
#'
#' @param dat An sf data.frame. Each row must represent a unique individual
#' organism in a unique year. This argument can be a data.frame that is returned
#' by the \code{\link{trackSpp}} function. It must have columns that contain a
#' unique identification for each research site (default name is "Site"),
#' species name (default name is "Species"), quadrat identifier (default name is
#' "Quad"), year of data collection (default name is "Year"), genet identity
#' (default name is "trackID"), and an s.f 'geometry' column that contains a
#' polygon or multipolygon data type for each individual observation.
#' by the \code{\link{trackSpp}} function. It must have columns that contain...
#' #' * a unique identification for each research site in character format
#' with no NAs (the default column name is "Site")
#' * species name in character format with no NAs (the default column
#' name is "Species")
#' * unique quadrat identifier in character format with no NAs (the default
#' column name is "Quad")
#' * year of data collection in integer format with no NAs (the
#' default column name is "Year")
#' * a unique identifier for each genet in character format with no NAs (the
#' default column name is "trackID")
#' * an s.f 'geometry' column that contains a polygon or multipolygon data type
#' for each individual observation (the default column name is "geometry")
#' @param buff A numeric value that is greater than or equal to zero. This
#' indicates the distance (in the same units as the spatial data in 'dat')
#' around each focal individual within which you want to look for competitors.
Expand Down
21 changes: 14 additions & 7 deletions R/getRecruits.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Calculates the number of recruits of each species per year in each quadrat
#'
#' @description This function calculates the number of new plant recruits of
#' @description This function calculates the number of new recruits of
#' each species in each quadrat in each year. The input data must already
#' contain a column indicating whether each observation is classified as a
#' recruit or not. This recruit status can be generated from the
Expand All @@ -12,12 +12,19 @@
#' @param dat An sf data.frame in which each row represents a unique polygon
#' (either a genet or a ramet) in a unique site/quadrat/year combination. A
#' data.frame returned by \code{\link{trackSpp}} can be put directly into this
#' function. 'dat' must have columns that contain a unique identification for
#' each research site (default name is "Site"), species name (default name is
#' "Species"), quadrat identifier (default name is "Quad"), year of data
#' collection (default name is "Year"), a unique identifier for each genet
#' (default name is 'trackID'), and an s.f 'geometry' column that contains a
#' polygon or multipolygon data type for each individual observation.
#' function. 'dat' must have columns that contain...
#' * a unique identification for each research site in character format
#' with no NAs (the default column name is "Site")
#' * species name in character format with no NAs (the default column
#' name is "Species")
#' * unique quadrat identifier in character format with no NAs (the default
#' column name is "Quad")
#' * year of data collection in integer format with no NAs (the
#' default column name is "Year")
#' * a unique identifier for each genet in character format with no NAs (the
#' default column name is "trackID")
#' * an s.f 'geometry' column that contains a polygon or multipolygon data type
#' for each individual observation (the default column name is "geometry")
#' @param byGenet A logical argument. `TRUE` indicates that a new genet will be
#' considered as only one recruit, even if it consists of multiple ramets.
#' `FALSE` indicates that each new ramet will be considered as a new recruit,
Expand Down
22 changes: 15 additions & 7 deletions R/trackSpp.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Tracks genets through time for multiple species and sites
#'
#' @description This function tracks individual plants in mapped quadrats
#' @description This function tracks individual organisms in mapped quadrats
#' through time to generate a demographic dataset that includes survival
#' and growth for each individual.
#'
Expand Down Expand Up @@ -32,12 +32,20 @@
#' package = "plantTracker")}
#'
#' @param dat An sf data.frame of the same format as
#' \code{\link{grasslandData}}. It must have columns that contain a unique
#' identification for each research site (default name is "Site"), species name
#' (default name is "Species"), quadrat identifier (default name is "Quad"),
#' year of data collection (default name is "Year") and an s.f 'geometry' column
#' that contains a polygon or multipolygon data type for each
#' individual observation. This function will add columns called
#' \code{\link{grasslandData}}. It must have columns that contain ...
#' #' * a unique identification for each research site in character format
#' with no NAs (the default column name is "Site")
#' * species name in character format with no NAs (the default column
#' name is "Species")
#' * unique quadrat identifier in character format with no NAs (the default
#' column name is "Quad")
#' * year of data collection in integer format with no NAs (the
#' default column name is "Year")
#' * an s.f 'geometry' column that contains a polygon or multipolygon data type
#' for each individual observation (the default column name is "geometry")
#' and an s.f 'geometry' column
#'
#' This function will add columns called
#' "basalArea_ramet", "trackID", "age", "size_tplus1", "recruit," "nearEdge,"
#' and "survives_tplus1", so 'dat' should not contain columns with these names.
#' @param inv A named list of the same format as
Expand Down
2 changes: 1 addition & 1 deletion man/aggregateByGenet.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading