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
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.6.8.21
Version: 1.6.8.22
Date: 2020-12-01
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -43,21 +43,22 @@ getSeriesAggregClass <- function(Format) {
}
.AggregConvertFunTable <- rbind(
data.frame(ConvertFun = "mean",
Outputs = c("Prod","Rout","Exp","SnowPack","ThermalState",
"Gratio","Temp","Gthreshold","Glocalmax","LayerTempMean", "T")),
data.frame(ConvertFun = "sum",
Outputs = c("PotEvap","Precip","Pn","Ps","AE","Perc","PR","Q9",
"Q1","Exch","AExch1","AExch2","AExch","QR","QRExp",
"QD","Qsim","Pliq","Psol","PotMelt","Melt","PliqAndMelt",
"LayerPrecip","LayerFracSolidPrecip", "Qmm", "Qls", "E", "P", "Qupstream"))
)
data.frame(ConvertFun = "mean",
Outputs = c("Prod","Rout","Exp","SnowPack","ThermalState",
"Gratio","Temp","Gthreshold","Glocalmax","LayerTempMean", "T"),
stringsAsFactors = FALSE), # R < 4.0 compatibility: avoids mixing numeric and factor into numeric in getAggregConvertFun()
data.frame(ConvertFun = "sum",
Outputs = c("PotEvap","Precip","Pn","Ps","AE","Perc","PR","Q9",
"Q1","Exch","AExch1","AExch2","AExch","QR","QRExp",
"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) {
res <- sapply(Outputs, function(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)
}
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