BiologicalRecordsCentre / sparta

Species Presence/Absence R Trends Analyses
http://biologicalrecordscentre.github.io/sparta/index.html
MIT License
21 stars 24 forks source link

Add error check to verify that visit identities are unique #158

Open drnickisaac opened 5 years ago

drnickisaac commented 5 years ago

Julie Sheard (and @galinajonsson ) have both been creating data for occDetFuncoutside of formatOccData, in order to integrate multiple data types. Julie has run into a problem in which the visits are not unique (i.e. an error in her data prep code). It should be very easy to check this and return a useful error message. In fact, there are two checks:

nrow(occDetdata) == nrow(spp_vis) length(unique(occDetdata$visit)) == nrow(occDetdata) length(unique(spp_vis$visit)) == nrow(spp_vis)

If these checks fail, it should be easy to return an informative error, such as:

temp <- table(spp_vis$visit)
paste(sum(table(temp)[-1]), " visits are duplicated in the spp_vis table")
paste("duplicate visits include", head(names(temp)[temp>1])