summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DESCRIPTION3
-rw-r--r--NAMESPACE1
-rw-r--r--R/preprocess.R9
3 files changed, 8 insertions, 5 deletions
diff --git a/DESCRIPTION b/DESCRIPTION
index c2f60b5..6a02705 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -12,5 +12,6 @@ Description: The sysid package provides functions for constructing mathematical
License: GPL-3
Depends: R (>= 3.1)
Imports:
- signal,tframe, zoo, ggplot2 (>= 2.1.0), reshape2, polynom, bitops
+ signal,tframe, ggplot2 (>= 2.1.0), reshape2, polynom, bitops
RoxygenNote: 5.0.1
+Suggests: zoo
diff --git a/NAMESPACE b/NAMESPACE
index 6993d08..5350368 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -70,4 +70,3 @@ import(polynom)
import(reshape2)
import(signal)
import(tframe)
-importFrom(zoo,na.approx)
diff --git a/R/preprocess.R b/R/preprocess.R
index c8435db..7bdada3 100644
--- a/R/preprocess.R
+++ b/R/preprocess.R
@@ -114,16 +114,19 @@ trInfo <- function(InputOffset=numeric(0),OutputOffset=numeric(0),
#' summary(cstr_mis) # finding out the number of NAs
#' cstr <- misdata(cstr_mis)
#'
-#' @importFrom zoo na.approx
#' @export
misdata <- function(data){
+ if (!requireNamespace("zoo", quietly = TRUE)) {
+ stop("Package zoo needed for this function to work. Please install it.",
+ call. = FALSE)
+ }
f <- function(var,start,end,Ts){
time_range <- range(time(var))
start <- time_range[1];end <- time_range[2]
- Ts <- deltat(var)
+ Ts <- stats::deltat(var)
var <- ts(data=var,start=start,end=end,deltat=Ts)
- out <- na.approx(var,na.rm=F)
+ out <- zoo::na.approx(var,na.rm=F)
return(as.numeric(out))
}