Skip to content

Commit

Permalink
fix dates
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Ruete committed Nov 12, 2020
1 parent 4b3a0fc commit 65665d5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/exportBirds.R
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,11 @@ exportTemporal <- function(sb, timeRes, variable, method){
if (timeRes %in% c("yearly", "monthly", "daily")){
if (method != "sum") stop("This combination of variable and time resolution only accepts 'sum' as summary method")
resVar <- pull(res, !!sym(variable))
names(resVar) <- switch(timeRes,
names(resVar) <- lubridate::ymd(switch(timeRes,
"yearly" = paste0(yearsAll, "-01-01"),
"monthly"= paste0(res$year, "-", sprintf("%02d", res$month), "-01"),
"daily" = paste0(res$year, "-", sprintf("%02d", res$month), "-", sprintf("%02d", res$day)))
)
# MAKE RESVAR to xts::as.xts()
resVar <- xts::as.xts(resVar)

Expand Down Expand Up @@ -301,10 +302,10 @@ exportTemporal <- function(sb, timeRes, variable, method){
if (timeRes %in% c("yearly", "monthly", "daily")){
if (method != "median") stop("This combination of variable and time resolution only accepts 'median' as summary method")
resVar <- pull(res, .data$avgSll)
names(resVar) <- switch(timeRes,
names(resVar) <- lubridate::ymd(switch(timeRes,
"yearly" = paste0(yearsAll, "-01-01"),
"monthly"= paste0(res$year, "-", sprintf("%02d", res$month), "-01"),
"daily" = paste0(res$year, "-", sprintf("%02d", res$month), "-", sprintf("%02d", res$day)))
"daily" = paste0(res$year, "-", sprintf("%02d", res$month), "-", sprintf("%02d", res$day))))
resVar <- xts::as.xts(resVar)

} else { #month
Expand Down

0 comments on commit 65665d5

Please sign in to comment.