diff options
author | Suraj Yerramilli | 2015-01-29 21:01:24 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2015-01-29 21:01:24 +0530 |
commit | b8d13d5183148e08c6441230ea4106f314f15657 (patch) | |
tree | 201a744c5b425c92cccb76e86f866b06dce77b27 /R/readData.R | |
parent | bf782db25276d2b5e1cba9db0a0dc861cefe8f0b (diff) | |
download | SysID-R-code-b8d13d5183148e08c6441230ea4106f314f15657.tar.gz SysID-R-code-b8d13d5183148e08c6441230ea4106f314f15657.tar.bz2 SysID-R-code-b8d13d5183148e08c6441230ea4106f314f15657.zip |
added tUnit parameter to the reading functions
Diffstat (limited to 'R/readData.R')
-rw-r--r-- | R/readData.R | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/R/readData.R b/R/readData.R index 24bb25d..513ce67 100644 --- a/R/readData.R +++ b/R/readData.R @@ -3,12 +3,13 @@ #' Read the contents of an file in table format into a \code{idframe} object. #' #' @param data a \code{data.frame} object -#' @param ninputs the number of input columns. (Default: 1) -#' @param type indicates the domain of the data (Default:\code{"time"}) -#' @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 ninputs the number of input columns. (Default: 1) +#' @param type indicates the domain of the data (Default:\code{"time"}) +#' @param Ts sampling interval (Default: 1) +#' @param tUnit Time Unit (Default: "seconds") #' #' @details #' @@ -17,8 +18,8 @@ #' #' @return an idframe object #' @export -read.idframe <- function(data,ninputs=1,type=c("time","freq")[1], - Ts = 1,freqData=FALSE){ +read.idframe <- function(data,freqData=FALSE,ninputs=1, + type=c("time","freq")[1],Ts = 1,tUnit="time"){ if((type=="freq") && (freqData)){ @@ -27,14 +28,14 @@ read.idframe <- function(data,ninputs=1,type=c("time","freq")[1], outputs <- dat[,seq((ninputs+1),dim(dat)[2],by=1)] out <- idframe(output=outputs,input=inputs,type=type,Ts=Ts, - frequencies=frequencies) + frequencies=frequencies,tUnit=tUnit) } else{ inputs <- dat[,1:ninputs] outputs <- dat[,seq(ninputs,dim(dat)[2],by=1)] - out <- idframe(output=outputs,input=inputs,type=type,Ts=Ts) + out <- idframe(output=outputs,input=inputs,type=type,Ts=Ts,tUnit=tUnit) } return(out) @@ -56,6 +57,7 @@ read.idframe <- function(data,ninputs=1,type=c("time","freq")[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 ... additional arguments to be passed to the \code{\link[utils]{read.table}} function #' #' @details @@ -72,13 +74,15 @@ read.idframe <- function(data,ninputs=1,type=c("time","freq")[1], #' @export #' @seealso \code{\link[utils]{read.table}} read.table.idframe <- function(file,header=TRUE,sep=",",ninputs=1, - type=c("time","freq")[1],Ts = 1,freqData=FALSE,...){ + type=c("time","freq")[1],Ts = 1,freqData=FALSE, + tUnit="time",...){ # Read from file (default: csv file) dat <- read.table(file=file,header=header,sep=sep,...) # read from dataframe and return idframe object - out <- read.idframe(data,ninputs=ninputs,type=type,Ts = Ts,freqData=freqData) + out <- read.idframe(data,ninputs=ninputs,type=type,Ts = Ts, + freqData=freqData,tUnit=tUnit) return(out) } @@ -97,6 +101,7 @@ read.table.idframe <- function(file,header=TRUE,sep=",",ninputs=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 ... additional arguments to be passed to the \code{\link[xlsx]{read.xlsx2}} function #' #' @details @@ -117,7 +122,8 @@ read.table.idframe <- function(file,header=TRUE,sep=",",ninputs=1, #' @export #' @seealso \code{\link[xlsx]{read.xlsx2}} read.xls.idframe <- function(file,sheetName,header=TRUE,ninputs=1, - type=c("time","freq")[1],Ts = 1,freqData=FALSE,...){ + type=c("time","freq")[1],Ts = 1,freqData=FALSE,tUnit="time", + ...){ require(xlsx) @@ -125,6 +131,7 @@ read.xls.idframe <- function(file,sheetName,header=TRUE,ninputs=1, dat <- read.xlsx2(file=file,sheetName=sheetName,header=header,...) # read from dataframe and return idframe object - out <- read.idframe(data,ninputs=ninputs,type=type,Ts = Ts,freqData=freqData) + out <- read.idframe(data,ninputs=ninputs,type=type,Ts = Ts, + freqData=freqData,tUnit=tUnit) return(out) }
\ No newline at end of file |