aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2014-04-26 08:42:29 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2014-04-26 08:42:29 +0200
commit4a91212601c379498202f8a5cecdee085f2cbe0a (patch)
tree7dfbc3993949c86b4e9cec4fa9cf98b3a7889f1b /R
parent3ee9215cf50e9a5cf81195f051fdd8a9ae68dad8 (diff)
Fix the default case for obs_vars in plot.mkinfit()
Diffstat (limited to 'R')
-rw-r--r--R/plot.mkinfit.R16
1 files changed, 5 insertions, 11 deletions
diff --git a/R/plot.mkinfit.R b/R/plot.mkinfit.R
index 2b85977e..80cf45f4 100644
--- a/R/plot.mkinfit.R
+++ b/R/plot.mkinfit.R
@@ -18,7 +18,7 @@
if(getRversion() >= '2.15.1') utils::globalVariables(c("type", "variable", "observed"))
plot.mkinfit <- function(x, fit = x,
- obs_vars = vector(),
+ obs_vars = names(fit$mkinmod$map),
xlab = "Time", ylab = "Observed",
xlim = range(fit$data$time),
ylim = c(0, max(subset(fit$data, variable %in% obs_vars)$observed, na.rm = TRUE)),
@@ -31,12 +31,6 @@ plot.mkinfit <- function(x, fit = x,
solution_type = fit$solution_type
parms.all <- c(fit$bparms.optim, fit$bparms.fixed)
- obs_vars_all <- names(fit$mkinmod$map)
-
- if (length(obs_vars) > 0){
- vars <- intersect(obs_vars_all, obs_vars)
- } else vars <- obs_vars_all
-
ininames <- c(
rownames(subset(fit$start, type == "state")),
rownames(subset(fit$fixed, type == "state")))
@@ -64,13 +58,13 @@ plot.mkinfit <- function(x, fit = x,
}
# Plot the data and model output
names(col_obs) <- names(pch_obs) <- names(lty_obs) <- names(fit$mkinmod$map)
- for (obs_var in vars) {
+ for (obs_var in obs_vars) {
points(subset(fit$data, variable == obs_var, c(time, observed)),
pch = pch_obs[obs_var], col = col_obs[obs_var])
}
- matlines(out$time, out[vars], col = col_obs[vars], lty = lty_obs[vars])
+ matlines(out$time, out[obs_vars], col = col_obs[obs_vars], lty = lty_obs[obs_vars])
if (legend == TRUE) {
- legend(lpos, inset= inset, legend = vars,
- col = col_obs[vars], pch = pch_obs[vars], lty = lty_obs[vars])
+ legend(lpos, inset= inset, legend = obs_vars,
+ col = col_obs[obs_vars], pch = pch_obs[obs_vars], lty = lty_obs[obs_vars])
}
}

Contact - Imprint