Learn R Programming

invacost (version 1.1-6)

expandYearlyCosts: Expand cost values per year of the database over relevant periods of impact

Description

For costs that occur over several years, this function repeats the cost value per year over each year of the relevant period of impact.

Usage

expandYearlyCosts(costdb, startcolumn, endcolumn)

Value

A data.frame containing the 'InvaCost' database where all costs occurring over several years are repeated for each year.

Arguments

costdb

The 'InvaCost' database, usually obtained with data(invacost)

startcolumn

Name of the column containing starting years

endcolumn

Name of the column containing ending years

Author

Boris Leroy leroy.boris@gmail.com, Andrew Kramer, Anne-Charlotte Vaissière, Christophe Diagne

References

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. tools:::Rd_expr_doi("10.1111/2041-210X.13929")

Examples

Run this code
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
# \donttest{
db.over.time <- expandYearlyCosts(invacost,
                                  startcolumn = "Probable_starting_year_adjusted",
                                  endcolumn = "Probable_ending_year_adjusted")
                                  # }

Run the code above in your browser using DataLab