diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2015-10-24 11:16:28 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2015-10-24 11:22:44 +0200 |
commit | 5b851f3fdfeb86d4ae7bd3859e3b69e14e6cd01f (patch) | |
tree | f0a09c8d36ec337f08be97d353f474cec071c574 /R/gmkinws.R | |
parent | 2ee017354c9d56086ae74c988741cd2c92f98d86 (diff) |
Collect also observed model variables in gmkinws field observed
Diffstat (limited to 'R/gmkinws.R')
-rw-r--r-- | R/gmkinws.R | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/R/gmkinws.R b/R/gmkinws.R index d40294d..9ef68e1 100644 --- a/R/gmkinws.R +++ b/R/gmkinws.R @@ -74,7 +74,7 @@ gmkinws <- R6Class("gmkinws", add_ds = function(ds) { self$check_ds(ds) - if (is.na(self$ds)) self$ds <- plyr::compact(ds) + if (is.na(self$ds[1])) self$ds <- plyr::compact(ds) else self$ds <- append(self$ds, plyr::compact(ds)) self$update_observed() @@ -83,9 +83,13 @@ gmkinws <- R6Class("gmkinws", }, update_observed = function() { - if (is.na(self$ds[1])) self$observed = NULL - else self$observed = na.omit(unique(unlist(sapply(self$ds, function(x) - x$observed)))) + observed_ds <- if (is.na(self$ds[1])) NULL + else na.omit(unique(unlist(sapply(self$ds, function(x) x$observed)))) + + observed_m <- if (is.na(self$m[1])) NULL + else na.omit(unique(unlist(sapply(self$m, function(x) names(x$spec))))) + + self$observed = union(observed_ds, observed_m) }, delete_ds = function(i) { @@ -110,8 +114,11 @@ gmkinws <- R6Class("gmkinws", add_m = function(m) { self$check_m(m) - if (is.na(self$m)) self$m <- plyr::compact(m) + if (is.na(self$m[1])) self$m <- plyr::compact(m) else self$m = append(self$m, plyr::compact(m)) + + self$update_observed() + invisible(self) }, |