change_values {quadcleanR} | R Documentation |
Change values within a column
Description
Using two vectors, change the values in one column to a new set of values. Helpful if you need to change many values at once, like updating changes to site names or taxonomy.
Usage
change_values(data, column, from, to)
Arguments
data |
A data frame. |
column |
The column in which to change values. |
from |
A vector containing the values you wish to change. |
to |
A vector contain the values you want to change to, ensuring these
occur in the same order as the |
Value
A data frame containing new values within the specified column.
Examples
Sites <- c("One.jpg", "Two.jpg", "Three.jpg", "Four.jpg", "Five.jpg")
Dominant_Coral <- c("Acropora.sp", "Leptastrea.spp", "Acropora.sp",
"Acropora.sp", "Acropora.sp")
Dominant_Cover <- c(0.1, 0.4, 0.9, 0.2, 0.5)
Largest_Coral <- c("Acropora.sp", "Acropora.sp", "Psammocora.sp",
"Acropora.sp","Gardineroseris.spp")
coral_cover <- data.frame(Sites, Dominant_Coral, Dominant_Cover, Largest_Coral)
change_values(coral_cover, "Dominant_Coral",
c("Acropora.sp","Leptastrea.spp"), c("Acropora_tabulate", "Leptastrea.purpurea"))
[Package quadcleanR version 1.1.0 Index]