add_data | R Documentation |
Using key identifying columns, add additional columns to an existing data frame. This function allows you to match new columns based on specified IDs and you can choose what columns to add. Additionally you can specify the column number at which to add the new columns, so they are not added to the end of the data frame. Helpful for adding environmental or taxonomic data to your quadrat data.
add_data(data, add, cols, data_id, add_id, number = FALSE)
data |
A data frame you want to add columns to. |
add |
A data frame with columns you want to add to |
cols |
The column names from |
data_id |
The ID column in |
add_id |
The ID column in |
number |
The column number to start at to add the new columns, so they are not added to the end of the data frame. If not specified they will be added to the end of the data frame by default. |
A data frame with added columns.
Sites <- as.factor(c("One", "One", "One", "Two", "Two", "Three")) Transect <- as.factor(c("1-Deep", "1-Shallow", "2-Shallow", "1-Shallow", "1-Deep", "1")) coral_name <- c("Acropora.sp", "Leptastrea.sp", "Sinularia.sp", "Psammocora.sp", " Psammocora.sp", "Leptastrea.sp") prop_cover <- c(0.1, 0.6, 0.4, 0.9, 0.2, 0.5) coral_cover <- data.frame(Sites, Transect, coral_name, prop_cover) corals <- c("Acropora.sp", "Leptastrea.sp", "Psammocora.sp") lifehistory <- c("compeditive", "weedy", "stresstolerant") functionalgroup <- c("hardcoral", "hardcoral", "hardcoral") coral_info <- data.frame(corals, lifehistory, functionalgroup) add_data(data = coral_cover, add = coral_info, cols = c("lifehistory", "functionalgroup"), data_id = "coral_name", add_id = "corals", number = 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.