Skip to content

Commit 8a6399d

Browse files
committed
derived dataset - add maxyear param
1 parent f980a4e commit 8a6399d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

bin/16_Derived_dataset.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ option_list <- list(
6363

6464
## Additional filters
6565
make_option("--minyear", action="store", default=1945, type='integer', help="Minimum year of occurrence (default, 1945)"),
66+
make_option("--maxyear", action="store", default=NA, type='integer', help="Maximum year of occurrence"),
6667
make_option("--noextinct", action="store", default=NA, type='character', help="Remove extinct species (provide a file with extinct specieskeys)"),
6768
make_option("--excludehuman", action="store", default=TRUE, type='logical', help="Exclude human records (genus Homo)"),
6869
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) )
132133
LONMAX <- as.numeric( to_na(opt$lonmax) )
133134

134135
MINYEAR <- as.numeric(to_na( opt$minyear) )
136+
MAXYEAR <- as.numeric(to_na( opt$maxyear) )
137+
135138
EXTINCT <- to_na( opt$noextinct)
136139
EXCLUDEHUMAN <- as.logical( opt$excludehuman )
137140

@@ -178,6 +181,7 @@ cat(paste("Maximum longitude: ", LONMAX, "\n", sep = ""))
178181
cat(paste("Basis of record to include: ", BASISINCL, "\n", sep=""))
179182
cat(paste("Basis of record to exclude: ", BASISEXCL, "\n", sep=""))
180183
cat(paste("Minimum year of occurrence: ", MINYEAR, "\n", sep=""))
184+
cat(paste("Maximum year of occurrence: ", MAXYEAR, "\n", sep=""))
181185
cat(paste("List of extict species: ", EXTINCT, "\n", sep=""))
182186
cat(paste("Exclusion of human records: ", EXCLUDEHUMAN, "\n", sep=""))
183187
cat(paste("Round coordinates: ", ROUNDCOORDS, "\n", sep=""))
@@ -275,6 +279,7 @@ quiet <- function(x) {
275279
# LONMIN <- NA
276280
# LONMAX <- NA
277281
# MINYEAR <- 2005
282+
# MAXYEAR <- NA
278283
# EXTINCT <- NA
279284
# EXCLUDEHUMAN <- TRUE
280285
# BASISINCL <- NA
@@ -368,9 +373,13 @@ if(!is.na(BASISINCL) & !is.na(BASISEXCL)){
368373

369374
## Year
370375
if(!is.na(MINYEAR)){
371-
cat("..Filtering by collection date\n")
376+
cat("..Filtering by collection date (min year)\n")
372377
dsf <- dsf %>% filter(year >= MINYEAR)
373378
}
379+
if(!is.na(MAX)){
380+
cat("..Filtering by collection date (max year)\n")
381+
dsf <- dsf %>% filter(year <= MAX)
382+
}
374383

375384
## Taxonomy filters
376385
if(!is.na(PHYLUM)){

0 commit comments

Comments
 (0)