From 8a6399dd1c2f683c817743affdecdfdd7be5bbe9 Mon Sep 17 00:00:00 2001 From: Vladimir Mikryukov Date: Wed, 24 May 2023 12:00:39 +0300 Subject: [PATCH] derived dataset - add `maxyear` param --- bin/16_Derived_dataset.R | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/16_Derived_dataset.R b/bin/16_Derived_dataset.R index 3207b17..f3933a7 100755 --- a/bin/16_Derived_dataset.R +++ b/bin/16_Derived_dataset.R @@ -63,6 +63,7 @@ option_list <- list( ## Additional filters make_option("--minyear", action="store", default=1945, type='integer', help="Minimum year of occurrence (default, 1945)"), + make_option("--maxyear", action="store", default=NA, type='integer', help="Maximum year of occurrence"), make_option("--noextinct", action="store", default=NA, type='character', help="Remove extinct species (provide a file with extinct specieskeys)"), make_option("--excludehuman", action="store", default=TRUE, type='logical', help="Exclude human records (genus Homo)"), make_option("--basisofrecordinclude", action="store", default=NA, type='character', help="Basis of record to include from the data"), @@ -132,6 +133,8 @@ LONMIN <- as.numeric( to_na(opt$lonmin) ) LONMAX <- as.numeric( to_na(opt$lonmax) ) MINYEAR <- as.numeric(to_na( opt$minyear) ) +MAXYEAR <- as.numeric(to_na( opt$maxyear) ) + EXTINCT <- to_na( opt$noextinct) EXCLUDEHUMAN <- as.logical( opt$excludehuman ) @@ -178,6 +181,7 @@ cat(paste("Maximum longitude: ", LONMAX, "\n", sep = "")) cat(paste("Basis of record to include: ", BASISINCL, "\n", sep="")) cat(paste("Basis of record to exclude: ", BASISEXCL, "\n", sep="")) cat(paste("Minimum year of occurrence: ", MINYEAR, "\n", sep="")) +cat(paste("Maximum year of occurrence: ", MAXYEAR, "\n", sep="")) cat(paste("List of extict species: ", EXTINCT, "\n", sep="")) cat(paste("Exclusion of human records: ", EXCLUDEHUMAN, "\n", sep="")) cat(paste("Round coordinates: ", ROUNDCOORDS, "\n", sep="")) @@ -275,6 +279,7 @@ quiet <- function(x) { # LONMIN <- NA # LONMAX <- NA # MINYEAR <- 2005 +# MAXYEAR <- NA # EXTINCT <- NA # EXCLUDEHUMAN <- TRUE # BASISINCL <- NA @@ -368,9 +373,13 @@ if(!is.na(BASISINCL) & !is.na(BASISEXCL)){ ## Year if(!is.na(MINYEAR)){ - cat("..Filtering by collection date\n") + cat("..Filtering by collection date (min year)\n") dsf <- dsf %>% filter(year >= MINYEAR) } +if(!is.na(MAX)){ + cat("..Filtering by collection date (max year)\n") + dsf <- dsf %>% filter(year <= MAX) +} ## Taxonomy filters if(!is.na(PHYLUM)){