1818# ' @param ID ID for this recording
1919# ' @param starttime Start time for the recording as extracted from \link{ReadAndCalibrate}
2020# ' @param data Raw data as read by \link{ReadAndCalibrate}
21+ # ' @param parameters List with the definition of the parameters of the function.
2122# '
2223# ' @return Function does not return anything, it only generates the reports and
2324# ' visualizations in the \code{output_directory}.
2930# '
3031# ' @author Matthew N. Ahmadi <[email protected] >3132# ' @author Jairo H. Migueles <[email protected] >32- classify = function (data = NULL , sf = NULL ,
33+ classify = function (data = NULL , parameters = NULL , sf = NULL ,
3334 classifier = NULL , infoClassifier = NULL ,
3435 ID = NULL , starttime = NULL ) {
36+ # -------------------------------------------------------------------------
3537 # Original code provided by Matthew N. Ahmadi
3638 # Jairo H. Migueles cleaned the code and isolated the classify function here
39+ # -------------------------------------------------------------------------
40+ # get parameters
41+ if (! is.null(parameters )) {
42+ if (! " infoClassifier" %in% names(parameters )) {
43+ parameters $ infoClassifier = GetInfoClassifier(parameters $ classifier )
44+ }
45+ sf = parameters $ sf
46+ classifier = parameters $ classifier
47+ infoClassifier = parameters $ infoClassifier
48+ epoch = parameters $ infoClassifier
49+ }
3750 epoch = infoClassifier $ epoch
3851 # -------------------------------------------------------------------------
3952 # 1 - EXTRACT FEATURES
@@ -54,9 +67,12 @@ classify = function(data = NULL, sf = NULL,
5467 ts = as.data.frame(cbind(ts , laglead ))
5568 }
5669 # Timestamp and ID
57- timestamp = deriveTimestamps(from = starttime , length = nrow(ts ), epoch = epoch )
58- subject = rep(ID , nrow(ts ))
59- ts = as.data.frame(cbind(subject , timestamp , ts ))
70+ if (! is.null(starttime )) {
71+ timestamp = deriveTimestamps(from = starttime , length = nrow(ts ), epoch = epoch )
72+ if (! is.null(ID )) subject = rep(ID , nrow(ts )) else subject = NA
73+ ts = as.data.frame(cbind(subject , timestamp , ts ))
74+ }
75+ # round numeric columns
6076 numeric_columns = sapply(ts , mode ) == ' numeric'
6177 ts [numeric_columns ] = round(ts [numeric_columns ], 3 )
6278 ts = do.call(data.frame ,lapply(ts , function (x ) replace(x , is.infinite(x ), NA )))
0 commit comments