diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2020-04-14 11:45:49 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2020-04-14 11:58:35 +0200 |
commit | d4a49b4837de347d34b2c198de7342c34b0fab63 (patch) | |
tree | df63250c72d94221a0560a8480cda45e309aa88e /R | |
parent | 28914451ac0ccc5bade64d9a79b7897cc701360a (diff) |
Keep order of datasets in nlme_data, add a plot
Diffstat (limited to 'R')
-rw-r--r-- | R/nlme.R | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -33,6 +33,11 @@ #' mean_dp <- mean_degparms(f) #' grouped_data <- nlme_data(f) #' nlme_f <- nlme_function(f) +#' # These assignments are necessary for these objects to be +#' # visible to nlme and augPred when evaluation is done by +#' # pkgdown to generated the html docs. +#' assign("nlme_f", nlme_f, globalenv()) +#' assign("grouped_data", grouped_data, globalenv()) #' #' library(nlme) #' m_nlme <- nlme(value ~ nlme_f(name, time, parent_0, log_k_parent_sink), @@ -41,6 +46,7 @@ #' random = pdDiag(parent_0 + log_k_parent_sink ~ 1), #' start = mean_dp) #' summary(m_nlme) +#' plot(augPred(m_nlme, level = 0:1), layout = c(3, 1)) #' #' \dontrun{ #' # Test on some real data @@ -111,7 +117,7 @@ #' #' anova(f_nlme_fomc_sfo, f_nlme_sfo_sfo) #' } -#' @return A function that can be used with \code{link{nlme}} +#' @return A function that can be used with nlme #' @export nlme_function <- function(object) { if (nrow(object) > 1) stop("Only row objects allowed") @@ -204,9 +210,10 @@ nlme_data <- function(object) { names(ds_list) <- ds_names ds_nlme <- purrr::map_dfr(ds_list, function(x) x, .id = "ds") ds_nlme$variable <- as.character(ds_nlme$variable) + ds_nlme$ds <- ordered(ds_nlme$ds, levels = unique(ds_nlme$ds)) ds_nlme_renamed <- data.frame(ds = ds_nlme$ds, name = ds_nlme$variable, time = ds_nlme$time, value = ds_nlme$observed, stringsAsFactors = FALSE) - ds_nlme_grouped <- groupedData(value ~ time | ds, ds_nlme_renamed) + ds_nlme_grouped <- groupedData(value ~ time | ds, ds_nlme_renamed, order.groups = FALSE) return(ds_nlme_grouped) } |