knitr::opts_chunk$set(echo = TRUE)
options( max.print=50, vsc.use_httpgd = TRUE, device = 'windows' ) library(AIMtools) library(tidyverse) library(arcgisbinding) arc.check_product()
Check to see what plants are in LPI that are not in Species Richness
'%!in%' <- function(x,y)!('%in%'(x,y)) data_20<-load_data() rich<-sp_rich(data=data_20,unknowns=T)%>% rename(symbol=2, rich_count=3) lpi<-cover(data_20, type="detailed", by="plot")%>% count(PlotID,symbol)%>% rename(lpi_count=n)%>% filter(str_detect(symbol, ".{3,}")) left_join(lpi, rich, by=c("PlotID", "symbol"))%>% filter(is.na(rich_count)) ##write_csv("test_data/output/qa_qc/found_in_lpi_but_not_rich.csv") ## Check Function sp_rich_qc(data_20)
cover(data_20, type="detailed")%>% View() data_20$lpi_detail%>% dplyr::filter(stringr::str_detect(RecKey, "TRFO|COS01000"))%>% View() read_csv("data/plant_list/CO_Survey123_species_20200504.csv")%>% View()
rich%>% filter(PlotID=="SS-099")
library(tidyverse) plant_list<-read_csv("data/plant_list/CO_Survey123_species_20200504.csv") agol_20$unknown%>% filter(stringr::str_detect(PlotKey, "TRFO|COS01000"))%>% select(PlotID, FinalCode)%>% mutate(FinalCode=str_trim(FinalCode))%>% left_join(plant_list, by=c("FinalCode"="name"))%>% filter(is.na(label)) agol_20$unknown%>% filter(stringr::str_detect(PlotKey, "TRFO|COS01000"))%>% filter(is.na(FinalCode))%>% View()
library(magrittr) data_20[["unknown_plants"]]<-data_20$unknown_plants%>% dplyr::mutate(FinalCode==stringr::str_trim(FinalCode)) unknowns<-data_20$unknown_plants%>% dplyr::filter(stringr::str_detect(PlotKey, "TRFO|COS01000"))%>% dplyr::mutate(FinalCode=ifelse(is.na(FinalCode), UnknownCode, FinalCode))%>% dplyr::select(PlotID, FinalCode)%>% dplyr::filter(!is.na(FinalCode)) richness<-sp_rich(data_20) dplyr::left_join(unknowns, richness, by=c("PlotID", "FinalCode"="species_code") )%>% dplyr::mutate(FinalCode=stringr::str_trim(FinalCode))%>% dplyr::filter(is.na(count))%>% dplyr::select(PlotID, FinalCode)%>% dplyr::mutate(error=paste0(FinalCode, ": Found in Unknown Plant list but not in Species Richness on ", PlotID), fix=NA) sp_rich_qc(data_20)
library(AIMtools) library(arcgisbinding) arc.check_product() data_20<-load_data() unknown_qc(data_20) sp_rich_qc(data_20) qa_qc(data_20)
co_plant_list<-readr::read_csv("data/plant_list/co_plant_list_08262020.txt") accepted_symbols<-readr::read_csv("data/plant_list/co_plant_list_synonyms_10272020.csv")%>% dplyr::filter(`Accepted Symbol`==Symbol) readr::read_csv("data/plant_list/co_plant_list_synonyms_10272020.csv")%>% dplyr::filter(`Accepted Symbol`!=Symbol)%>% dplyr::select(-`Common Name`, -Family)%>% dplyr::left_join(dplyr::select(accepted_symbols, `Accepted Symbol`, `Common Name`, Family), by="Accepted Symbol")%>% dplyr::select(Symbol:Family)%>% dplyr::bind_rows(dplyr::select(accepted_symbols, Symbol:Family))%>% readr::write_csv("data/plant_list/plant_list_with_synonyms_10272020.csv")
library(AIMtools) library(arcgisbinding) library(magrittr) arc.check_product() agol_20<-load_data() agol_19<-load_data(year=2019) dima_18<-readRDS("test_cache/DIMA_2018.rds") count_20<-sp_rich(agol_20)%>% dplyr::count(species_code)%>% dplyr::rename(agol_20=n) count_19<-sp_rich(agol_19)%>% dplyr::count(species_code)%>% dplyr::rename(agol_19=n) count_18<-sp_rich_dima(dima_18)%>% dplyr::count(symbol)%>% dplyr::rename(species_code=symbol, dima_18=n) total_plants<-dplyr::full_join(count_18, count_19)%>% dplyr::full_join(count_20)%>% dplyr::filter(!stringr::str_detect(species_code, "^[A-Z]{2}[0-9]{2}")) plant_list<-readr::read_csv("data/plant_list/plant_list_with_synonyms_10272020.csv") plant_list%>% dplyr::filter(Symbol %in% c("ERLE10", "PORE", "LAPA5", "SYER", "CAFL", "FOPU2")) total_plants%>% dplyr::filter(is.na(agol_19)&is.na(dima_18))%>% dplyr::select(species_code)%>% dplyr::left_join(plant_list, by=c("species_code"="Symbol"))%>% readr::write_csv("test_data/output/qa_qc/new_species_2020_V2.csv") total_plants%>% dplyr::filter(is.na(agol_20)&is.na(dima_18))%>% View() sp_rich(agol_20)%>% dplyr::filter(species_code=="PLJA")
Plant_list for Synonyms
library(tidyverse) synonym_check<-readr::read_csv("data/plant_list/co_plant_list_synonyms_10272020.csv")%>% dplyr::select(`Accepted Symbol`, `Symbol`, `Scientific Name`) synonym_check%>% filter(str_detect(Symbol, "^PODO"))
Need to run this post all the checks!
total_plants%>% dplyr::left_join(synonym_check, by=c("species_code"="Symbol"))%>% dplyr::mutate(species_code=ifelse(`Accepted Symbol`==species_code, species_code, `Accepted Symbol`))%>% dplyr::select(-`Accepted Symbol`)%>% dplyr::mutate_if(is.numeric, tidyr::replace_na, replace=0)%>% dplyr::group_by(species_code, `Scientific Name`)%>% dplyr::summarise_if(is.numeric,sum)%>% dplyr::ungroup()%>% dplyr::mutate(total=(dima_18+agol_19+agol_20))%>% dplyr::rename(yr_2018=dima_18, yr_2019=agol_19, yr_2020=agol_20)%>% dplyr::arrange(desc(total))%>% write_csv("test_data/output/final_data/sp_rich/freqency_by_species_all_years.csv")
sp_rich(agol_20)%>% filter(str_detect(species_code, "[A-Z]{2}[0-9]{5}|XXXX$"))
sp_rich(agol_20)%>% dplyr::filter(species_code=="ROBL") unknown_qc(agol_20)
library(arcgisbinding) arc.check_product() library(tidyverse) library(devtools) library(AIMtools) load_all() data<-load_data() rich<-sp_rich(data=data,unknowns=T)%>% dplyr::rename(symbol=2, rich_count=3) lpi<-cover(data, type="detailed", by="plot")%>% dplyr::count(PlotID, symbol, PlotKey)%>% dplyr::rename(lpi_count=n)%>% dplyr::filter(stringr::str_detect(symbol, ".{3,}")) lpi_check<-dplyr::left_join(lpi, rich, by=c("PlotID", "symbol"))%>% dplyr::filter(is.na(rich_count))%>% dplyr::select(PlotID, symbol, PlotKey)%>% dplyr::mutate(error="Symbol appears in LPI form but not in Species Richness", fix=paste0("Add this symbol to Species Richness to plot ", PlotID)) unknowns<-data$unknown_plants%>% dplyr::select(PlotID, Office, PlotKey, UnknownCode, FinalCode)%>% dplyr::mutate(FinalCode=ifelse(is.na(FinalCode), UnknownCode, FinalCode))%>% dplyr::filter(!is.na(FinalCode)) richness<-sp_rich(data) unknown_check<-dplyr::left_join(unknowns, richness, by=c("PlotID", "FinalCode"="species_code") )%>% dplyr::filter(is.na(count))%>% dplyr::select(PlotID, UnknownCode, Office, PlotKey)%>% dplyr::rename(symbol=UnknownCode)%>% dplyr::mutate(error=paste0(symbol, ": Found in Unknown Plant list but not in Species Richness on ", PlotID), fix=NA) final_check<-dplyr::bind_rows(unknown_check, lpi_check)
data$plots%>% filter_fo()%>% filter(panel!="Oversample")%>% count(EvalStatus)
qa_qc_2021<-qa_qc(data) qa_qc_2021$sp_rich_check%>% filter_fo()%>% View()
library(arcgisbinding) arc.check_product() library(tidyverse) library(devtools) library(AIMtools) library(here) data<-load_data(year=2021) data$plots%>% filter_fo()%>% count(EvalStatus) qaqc<-qa_qc(data)%>% lapply(filter_fo) qaqc$unknown_symbol_check%>% write_csv(here("test/output/qaqc_2021_unknown_symbol_check.csv")) qaqc$sp_rich_check%>% write_csv(here("test/output/qaqc_2021_sp_rich_check.csv"))
dima<-read_dima("test_data/DIMA_2021.mdb")
dima_cover(dima)%>% filter(is.na(list_name), symbol!="None")%>% select(symbol, LineID, PlotID)%>% mutate(fix = "Symbol does not match plant list. Revise to species that is on the plant list.")%>% write_csv("test_data/output/qa_qc_DIMA_2021_LPI.csv")
sp_rich_dima(dima)%>% left_join(dima$plant_list, by=c("symbol" = "name"))%>% filter(is.na(list_name))%>% mutate(error = "Not found in Plant list. Correct or replace with Synonym.")%>% write_csv("test_data/output/qa_qc_DIMA_2021_sp_rich.csv") dima$plant_list
library(AIMtools) library(tidyverse) data<-readRDS("test_cache/agol_2022_08.rds") qa_qc(data) rich<-sp_rich(data, unknowns=T)%>% dplyr::rename(symbol=2, rich_count=3) lpi<-cover(data, type="detailed", by="plot")%>% dplyr::count(PlotID, symbol, PlotKey)%>% dplyr::rename(lpi_count=n)%>% dplyr::filter(stringr::str_detect(symbol, ".{3,}")) lpi_check<-dplyr::left_join(lpi, rich, by=c("PlotID" = "symbol")) qa_qc(data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.