Replaces specific receiver locations in the detections dataframe with aggregated sites, updating their River Kilometer (RKM), Latitude (Lat), Longitude (Lon), and Region accordingly.

aggregate_detections_sacramento(
  detections,
  receiever_metadata,
  replace_dict = list(replace_with = list(c("Releasepoint"), c("WoodsonBridge"),
    c("Sacramento"), c("Endpoint")), replace_list = list(c("BattleCk_CNFH_Rel",
    "RBDD_Rel", "RBDD_Rel_Rec", "Altube Island", "Abv_Altube1", "MillCk_RST_Rel",
    "MillCk2_Rel", "DeerCk_RST_Rel"), c("Mill_Ck_Conf", "Abv_WoodsonBr", "Blw_Woodson"),
    c("TowerBridge", "I80-50_Br", "ToeDrainBase", "Hwy84Ferry"), c("BeniciaE",
    "BeniciaW", "ChippsE", "ChippsW")))
)

Arguments

detections

A dataframe containing detections information.

receiever_metadata

A table containing metadata for general release sites. Created using get_reciever_sites_metadata().

replace_dict

A list specifying receiver locations to aggregate and their corresponding aggregated names.

Value

A dataframe of detections with aggregated receiver sites and updated metadata.

Details

This function replaces specified receiver locations in the detections dataframe with aggregated sites according to the provided replace dictionary. It updates the River Kilometer (RKM), Latitude (Lat), Longitude (Lon), and Region for the aggregated sites. The function creates a new dataframe containing the aggregated receiver sites' metadata, reflecting the aggregation done.

Examples

# Define replace dictionary
replace_dict <- list(replace_with = list(c("Releasepoint"),
                                         c("WoodsonBridge"),
                                         c("Sacramento"),
                                         c("Endpoint")),
                    replace_list = list(c("BattleCk_CNFH_Rel","RBDD_Rel","RBDD_Rel_Rec",
                                          "Altube Island","Abv_Altube1",
                                          "MillCk_RST_Rel","MillCk2_Rel","DeerCk_RST_Rel"),
                                        c("Mill_Ck_Conf","Abv_WoodsonBr","Blw_Woodson"),
                                        c("TowerBridge","I80-50_Br",
                                          "ToeDrainBase","Hwy84Ferry"),
                                        c("BeniciaE","BeniciaW",
                                          "ChippsE","ChippsW")))

# Aggregate detections data for Sacramento River sites
aggregated_detections <- aggregate_detections_sacramento(detections_data, replace_dict)
#> Error in receiever_metadata %>% select(receiver_general_location, receiver_general_river_km,     receiver_general_latitude, receiver_general_longitude, receiver_region) %>%     filter(receiver_general_location %in% c(replace_list, replace_with)) %>%     distinct() %>% select(-receiver_general_location) %>% group_by(receiver_region) %>%     summarise_all(mean): could not find function "%>%"