Created
September 28, 2020 19:27
-
-
Save jsta/4b8be3f41da11ee11c08523cba73c129 to your computer and use it in GitHub Desktop.
Verify that adding ability to pass model number as a variable doesn't cause rloadest output changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rloadest) | |
my_model_no <- 1 | |
loadreg_original <- loadReg(Phosphorus ~ model(1), | |
data = app1.calib, dates = "DATES", flow = "FLOW") | |
loadreg_mod <- loadReg(as.formula(paste0("Phosphorus ~ model(", my_model_no, ")")), | |
data = app1.calib, dates = "DATES", flow = "FLOW") | |
identical( | |
loadreg_original, | |
loadreg_mod | |
) | |
# FALSE | |
identical(coef(loadreg_mod$cfit), | |
coef(loadreg_original$cfit)) | |
# TRUE | |
(whats_changed <- names(loadreg_original)[ | |
!unlist( | |
lapply(seq_len(length(loadreg_mod)), | |
function(i) identical( | |
loadreg_original[[i]], | |
loadreg_mod[[i]])) | |
) | |
]) | |
# [1] "lfit" "cfit" | |
(what_changed_cfit <- names(loadreg_original$cfit)[ | |
!unlist( | |
lapply(seq_len(length(loadreg_mod$cfit)), | |
function(i) identical( | |
loadreg_original$cfit[[i]], | |
loadreg_mod$cfit[[i]])) | |
) | |
]) | |
# [1] "call" "terms" | |
identical( | |
loadreg_mod$cfit$call, | |
loadreg_original$cfit$call | |
) | |
# FALSE | |
loadreg_mod$cfit$call | |
# loadReg(formula = as.formula(paste0("Phosphorus ~ model(", my_model_no, | |
# ")")), data = app1.calib, flow = "FLOW", dates = "DATES") | |
loadreg_original$cfit$call | |
# loadReg(formula = Phosphorus ~ model(1), data = app1.calib, flow = "FLOW", | |
# dates = "DATES") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Printing
loadreg_mod
withbrief=FALSE
doesn't error but it does give some strange output: