diff options
Diffstat (limited to 'R')
-rw-r--r-- | R/readData.R | 52 |
1 files changed, 12 insertions, 40 deletions
diff --git a/R/readData.R b/R/readData.R index 16789c0..b66eeb6 100644 --- a/R/readData.R +++ b/R/readData.R @@ -3,30 +3,22 @@ #' Read the contents of a data.frame/matrix into a \code{idframe} object. #' #' @param data a \code{data.frame} object -#' @param freqData a logical value indicating whether the file contains the list of -#' frequencies. If \code{TRUE}, they need to be present in the first column. -#' (Default: \code{idframe}) -#' @param ninputs the number of input columns. (Default: \code{NULL}) -#' @param type indicates the domain of the data (Default:\code{"time"}) +#' @param ninputs the number of input columns. (Default: 0) #' @param Ts sampling interval (Default: 1) -#' @param tUnit Time Unit (Default: "seconds") +#' @param unit Time Unit (Default: "seconds") #' -#' @details -#' -#' If \code{type="freq"} and \code{freqData = TRUE}, then the first column in the file -#' should contain the frequencies. #' #' @return an idframe object #' @examples #' data(cstr) -#' data <- read.idframe(cstrData,ninputs=1,type="time",Ts= 1,tUnit="min") +#' data <- read.idframe(cstrData,ninputs=1,Ts= 1,unit="minutes") #' #' @export read.idframe <- function(data,ninputs=NULL,Ts = 1, unit=c("seconds","minutes","hours", "days","hours")[1]){ outIndex <- 1:dim(data)[2]; inputs <- NULL - if(!is.null(ninputs)){ + if(ninputs==0){ inputs <- data[,1:ninputs,drop=F] outIndex <- seq(ninputs+1,dim(data)[2],by=1) } @@ -47,13 +39,9 @@ read.idframe <- function(data,ninputs=NULL,Ts = 1, #' @param header a logical value indicating whether the first row corresponding to #' the first element of the rowIndex vector contains the names of the variables. #' (Default: \code{TRUE}) -#' @param ninputs the number of input columns. (Default: \code{NULL}) -#' @param type indicates the domain of the data (Default:\code{"time"}) +#' @param ninputs the number of input columns. (Default: 0) #' @param Ts sampling interval (Default: 1) -#' @param freqData a logical value indicating whether the file contains the list of -#' frequencies. If \code{TRUE}, they need to be present in the first column. -#' (Default: \code{idframe}) -#' @param tUnit Time Unit (Default: "seconds") +#' @param unit Time Unit (Default: "seconds") #' @param ... additional arguments to be passed to the \code{\link[utils]{read.table}} function #' #' @details @@ -62,21 +50,17 @@ read.idframe <- function(data,ninputs=NULL,Ts = 1, #' provided by the \pkg{utils} package, to read data from a table-formatted file and then calls the #' \code{\link{read.idframe}} function to read the data into a idframe object #' -#' -#' If \code{type="freq"} and \code{freqData = TRUE}, then the first column in the file -#' should contain the frequencies. -#' #' @return an idframe object #' @examples #' dataMatrix <- data.frame(matrix(rnorm(1000),ncol=5)) #' colnames(dataMatrix) <- c("u1","u2","y1","y2","y3") #' write.csv(dataMatrix,file="test.csv",row.names=FALSE) #' -#' data <- read.table.idframe("test.csv",ninputs=2,tUnit="min") +#' data <- read.table.idframe("test.csv",ninputs=2,unit="minutes") #' #' @seealso \code{\link[utils]{read.table}} #' @export -read.table.idframe <- function(file,header=TRUE,sep=",",ninputs=NULL, +read.table.idframe <- function(file,header=TRUE,sep=",",ninputs=0, Ts = 1,unit=c("seconds","minutes","hours", "days","hours")[1],...){ @@ -94,16 +78,9 @@ read.table.idframe <- function(file,header=TRUE,sep=",",ninputs=NULL, #' #' @param file the path to the file to read #' @param sheetName a character string with the sheet name -#' @param header a logical value indicating whether the first row corresponding to -#' the first element of the rowIndex vector contains the names of the variables. -#' (Default: \code{TRUE}) -#' @param ninputs the number of input columns. (Default: \code{NULL}) -#' @param type indicates the domain of the data (Default:\code{"time"}) +#' @param ninputs the number of input columns. (Default: 0) #' @param Ts sampling interval (Default: 1) -#' @param freqData a logical value indicating whether the file contains the list of -#' frequencies. If \code{TRUE}, they need to be present in the first column. -#' (Default: \code{idframe}) -#' @param tUnit Time Unit (Default: "seconds") +#' @param unit Time Unit (Default: "seconds") #' @param ... additional arguments to be passed to the \code{\link[xlsx]{read.xlsx2}} function #' #' @details @@ -112,11 +89,6 @@ read.table.idframe <- function(file,header=TRUE,sep=",",ninputs=NULL, #' provided by the \pkg{xlsx} package, to read data from an excel file and then calls the #' \code{\link{read.idframe}} function to read the data into a idframe object #' -#' -#' If \code{type="freq"} and \code{freqData = TRUE}, then the first column in the file -#' should contain the frequencies. -#' -#' #' The function requires the java runtime to be installed on the system (Requirement of #' the \pkg{xlsx} package). #' @@ -127,11 +99,11 @@ read.table.idframe <- function(file,header=TRUE,sep=",",ninputs=NULL, #' colnames(dataMatrix) <- c("u1","u2","y1","y2","y3") #' write.xlsx2(dataMatrix,file="test.xlsx",row.names=FALSE) #' -#' data <- read.xls.idframe("test.xlsx","Sheet1",ninputs=2,tUnit="min") +#' data <- read.xls.idframe("test.xlsx","Sheet1",ninputs=2,unit="minutes") #' #' @seealso \code{\link[xlsx]{read.xlsx2}} #' @export -read.xls.idframe <- function(file,sheetName,header=TRUE,ninputs=NULL, +read.xls.idframe <- function(file,sheetName,header=TRUE,ninputs=0, Ts = 1,unit=c("seconds","minutes","hours", "days","hours")[1],...){ |