From b2e3fa2be6a10c29030d04edfdaf7d47d9bddcee Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 23 Nov 2018 00:29:35 +0100 Subject: Improve initialisation of mkinds Check in work from the beginning of the week --- R/mkinds.R | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/R/mkinds.R b/R/mkinds.R index 60924c21..bed49be3 100644 --- a/R/mkinds.R +++ b/R/mkinds.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Johannes Ranke +# Copyright (C) 2015,2018 Johannes Ranke # Contact: jranke@uni-bremen.de # This file is part of the R package mkin @@ -43,13 +43,16 @@ mkinds <- R6Class("mkinds", initialize = function(title = "", data, time_unit = NA, unit = NA) { - self$title = title - self$sampling_times = sort(unique(data$time)) - self$time_unit = time_unit - self$observed = unique(data$name) - self$unit = unit - self$replicates = max(by(data, list(data$name, data$time), nrow)) - self$data = data + self$title <- title + self$sampling_times <- sort(unique(data$time)) + self$time_unit <- time_unit + self$observed <- unique(data$name) + self$unit <- unit + self$replicates <- max(by(data, list(data$name, data$time), nrow)) + if (is.null(data$override)) data$override <- NA + if (is.null(data$err)) data$err <- 1 + self$data <- data + } ) ) @@ -60,6 +63,6 @@ print.mkinds <- function(x, ...) { cat("Observed compounds $observed: ", paste(x$observed, collapse = ", "), "\n") cat("Sampling times $sampling_times: ", paste(x$sampling_times, collapse = ", "), "\n") cat("With a maximum of ", x$replicates, " replicates\n") - if (!is.na(x$time_unit)) cat("Time units: ", x$time_units, "\n") - if (!is.na(x$unit)) cat("Observation units: ", x$units, "\n") + if (!is.na(x$time_unit)) cat("Time unit: ", x$time_unit, "\n") + if (!is.na(x$unit)) cat("Observation unit: ", x$unit, "\n") } -- cgit v1.2.1