View source: R/summarizeCosts.R
summarizeCosts | R Documentation |
This function summarizes the cumulative costs and average annual costs of invasive alien species and breaks it down into regular periods of time, on the basis of cost estimates as they appeared in the provided in the source references collected in the 'InvaCost' database
summarizeCosts(
costdb,
cost.column = "Cost_estimate_per_year_2017_USD_exchange_rate",
year.column = "Impact_year",
in.millions = TRUE,
minimum.year = 1960,
maximum.year = max(costdb[, year.column]),
year.breaks = seq(minimum.year, maximum.year, by = 10),
include.last.year = TRUE
)
costdb |
The expanded 'InvaCost' database output from
|
cost.column |
Name of the cost column to use in |
year.column |
Name of the year column to use in |
in.millions |
If |
minimum.year |
The starting year of the analysis. By default, 1960 was chosen because it marks the period from which world bank data is available for exchange rates and inflation values. |
maximum.year |
The ending year for the analysis. By default, the last
year of |
year.breaks |
A vector of breaks for the year intervals over which you want to summarize cost values |
include.last.year |
|
Missing data are ignored. However, note that the average for each interval is always calculated on the basis of the full temporal range. For example, if there is only data for 1968 for the 1960-1969 interval, then the total cost for the interval will be equal to the cost of 1968, and the average annual cost for 1960-1969 will be the cost of 1968 / 10.
A list
with 6 elements:
cost.data
: the input data
parameters
: parameters used to run the function. The
minimum.year
and maximum.year
are based on the input data
(i.e., the user may specify minimum.year = 1960
but the input data may
only have data starting from 1970, hence the minimum.year
will be
1970)
year.breaks
: the years used to define year intervals over which costs were calculated.
cost.per.year
: the costs of invasions expressed per year,
as sums of all costs for each year
average.total.cost
: the average annual cost of invasive Alien
species calculated
over the entire time period
average.cost.per.period
: a data.frame containing the average
annual cost of invasive alien species calculated over each time interval
The structure of this object can be seen using str()
.
Boris Leroy leroy.boris@gmail.com, Andrew Kramer, Anne-Charlotte Vaissière, Christophe Diagne
https://github.com/Farewe/invacost
Leroy Boris, Kramer Andrew M, Vaissière Anne-Charlotte, Kourantidou Melina, Courchamp Franck & Diagne Christophe (2022). Analysing economic costs of invasive alien species with the invacost R package. Methods in Ecology and Evolution. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/2041-210X.13929")}
expandYearlyCosts
to get the database in appropriate format.
data(invacost)
### Cleaning steps
# Eliminating data with no information on starting and ending years
invacost <- invacost[-which(is.na(invacost$Probable_starting_year_adjusted)), ]
invacost <- invacost[-which(is.na(invacost$Probable_ending_year_adjusted)), ]
# Keeping only observed and reliable costs
invacost <- invacost[invacost$Implementation == "Observed", ]
invacost <- invacost[which(invacost$Method_reliability == "High"), ]
# Eliminating data with no usable cost value
invacost <- invacost[-which(is.na(invacost$Cost_estimate_per_year_2017_USD_exchange_rate)), ]
### Expansion
db.over.time <- expandYearlyCosts(invacost,
startcolumn = "Probable_starting_year_adjusted",
endcolumn = "Probable_ending_year_adjusted")
### Analysis
res <- summarizeCosts(db.over.time,
maximum.year = 2020) # Excluding data after 2020 (e.g. planned budgets)
res
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.