Commit a106f301 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.6.8.22 fix(SeriesAggreg): force character format to .AggregConvertFunTable

- in order getAggregConvertFun to be compatible qith R < 4.0 (stringAsFactors = TRUE)
Refs #41
Showing with 13 additions and 12 deletions
+13 -12
Package: airGR Package: airGR
Type: Package Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.6.8.21 Version: 1.6.8.22
Date: 2020-12-01 Date: 2020-12-01
Authors@R: c( Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
...@@ -43,21 +43,22 @@ getSeriesAggregClass <- function(Format) { ...@@ -43,21 +43,22 @@ getSeriesAggregClass <- function(Format) {
} }
.AggregConvertFunTable <- rbind( .AggregConvertFunTable <- rbind(
data.frame(ConvertFun = "mean", data.frame(ConvertFun = "mean",
Outputs = c("Prod","Rout","Exp","SnowPack","ThermalState", Outputs = c("Prod","Rout","Exp","SnowPack","ThermalState",
"Gratio","Temp","Gthreshold","Glocalmax","LayerTempMean", "T")), "Gratio","Temp","Gthreshold","Glocalmax","LayerTempMean", "T"),
data.frame(ConvertFun = "sum", stringsAsFactors = FALSE), # R < 4.0 compatibility: avoids mixing numeric and factor into numeric in getAggregConvertFun()
Outputs = c("PotEvap","Precip","Pn","Ps","AE","Perc","PR","Q9", data.frame(ConvertFun = "sum",
"Q1","Exch","AExch1","AExch2","AExch","QR","QRExp", Outputs = c("PotEvap","Precip","Pn","Ps","AE","Perc","PR","Q9",
"QD","Qsim","Pliq","Psol","PotMelt","Melt","PliqAndMelt", "Q1","Exch","AExch1","AExch2","AExch","QR","QRExp",
"LayerPrecip","LayerFracSolidPrecip", "Qmm", "Qls", "E", "P", "Qupstream")) "QD","Qsim","Pliq","Psol","PotMelt","Melt","PliqAndMelt",
) "LayerPrecip","LayerFracSolidPrecip", "Qmm", "Qls", "E", "P", "Qupstream"),
stringsAsFactors = FALSE) # R < 4.0 compatibility: avoids mixing numeric and factor into numeric in getAggregConvertFun()
)
getAggregConvertFun <- function(Outputs) { getAggregConvertFun <- function(Outputs) {
res <- sapply(Outputs, function(iOutputs) { res <- sapply(Outputs, function(iOutputs) {
iRes <- .AggregConvertFunTable$ConvertFun[.AggregConvertFunTable$Outputs == iOutputs] iRes <- .AggregConvertFunTable$ConvertFun[.AggregConvertFunTable$Outputs == iOutputs]
iRes <- ifelse(any(is.na(iRes)), NA, iRes) iRes <- ifelse(any(is.na(iRes)), NA, iRes) # R < 4.0 compatibility
}) })
return(res) return(res)
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment