Skip to content

Commit

Permalink
derived dataset - add maxyear param
Browse files Browse the repository at this point in the history
  • Loading branch information
vmikk committed May 24, 2023
1 parent f980a4e commit 8a6399d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bin/16_Derived_dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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 )

Expand Down Expand Up @@ -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=""))
Expand Down Expand Up @@ -275,6 +279,7 @@ quiet <- function(x) {
# LONMIN <- NA
# LONMAX <- NA
# MINYEAR <- 2005
# MAXYEAR <- NA
# EXTINCT <- NA
# EXCLUDEHUMAN <- TRUE
# BASISINCL <- NA
Expand Down Expand Up @@ -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)){
Expand Down

0 comments on commit 8a6399d

Please sign in to comment.