From 5b851f3fdfeb86d4ae7bd3859e3b69e14e6cd01f Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sat, 24 Oct 2015 11:16:28 +0200 Subject: Collect also observed model variables in gmkinws field observed --- R/gmkinws.R | 17 ++++++++++++----- data/FOCUS_2006.RData | Bin 21120 -> 22120 bytes data/FOCUS_2006_Z.RData | Bin 51043 -> 66836 bytes 3 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) }, diff --git a/data/FOCUS_2006.RData b/data/FOCUS_2006.RData index 9d27ed8..9c8e30d 100644 Binary files a/data/FOCUS_2006.RData and b/data/FOCUS_2006.RData differ diff --git a/data/FOCUS_2006_Z.RData b/data/FOCUS_2006_Z.RData index cd5defb..0bb2b51 100644 Binary files a/data/FOCUS_2006_Z.RData and b/data/FOCUS_2006_Z.RData differ -- cgit v1.2.1