summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--R/readData.R52
-rw-r--r--man/read.idframe.Rd20
-rw-r--r--man/read.table.idframe.Rd21
-rw-r--r--man/read.xls.idframe.Rd26
4 files changed, 27 insertions, 92 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],...){
diff --git a/man/read.idframe.Rd b/man/read.idframe.Rd
index 216c074..adcc72c 100644
--- a/man/read.idframe.Rd
+++ b/man/read.idframe.Rd
@@ -4,23 +4,17 @@
\alias{read.idframe}
\title{Data input into a idframe object}
\usage{
-read.idframe(data, freqData = FALSE, ninputs = NULL, type = c("time",
- "freq")[1], Ts = 1, tUnit = "sec")
+read.idframe(data, ninputs = NULL, Ts = 1, unit = c("seconds", "minutes",
+ "hours", "days", "hours")[1])
}
\arguments{
\item{data}{a \code{data.frame} object}
-\item{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})}
-
-\item{ninputs}{the number of input columns. (Default: \code{NULL})}
-
-\item{type}{indicates the domain of the data (Default:\code{"time"})}
+\item{ninputs}{the number of input columns. (Default: 0)}
\item{Ts}{sampling interval (Default: 1)}
-\item{tUnit}{Time Unit (Default: "seconds")}
+\item{unit}{Time Unit (Default: "seconds")}
}
\value{
an idframe object
@@ -28,12 +22,8 @@ an idframe object
\description{
Read the contents of a data.frame/matrix into a \code{idframe} object.
}
-\details{
-If \code{type="freq"} and \code{freqData = TRUE}, then the first column in the file
-should contain the frequencies.
-}
\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")
}
diff --git a/man/read.table.idframe.Rd b/man/read.table.idframe.Rd
index 73f4082..5785201 100644
--- a/man/read.table.idframe.Rd
+++ b/man/read.table.idframe.Rd
@@ -4,9 +4,8 @@
\alias{read.table.idframe}
\title{Read the contents of a table-formatted file}
\usage{
-read.table.idframe(file, header = TRUE, sep = ",", ninputs = NULL,
- type = c("time", "freq")[1], Ts = 1, freqData = FALSE, tUnit = "sec",
- ...)
+read.table.idframe(file, header = TRUE, sep = ",", ninputs = 0, Ts = 1,
+ unit = c("seconds", "minutes", "hours", "days", "hours")[1], ...)
}
\arguments{
\item{file}{the path to the file to read}
@@ -18,17 +17,11 @@ the first element of the rowIndex vector contains the names of the variables.
\item{sep}{the field separator character. Values on each line of the file are
separated by this character. (Default: \code{","})}
-\item{ninputs}{the number of input columns. (Default: \code{NULL})}
-
-\item{type}{indicates the domain of the data (Default:\code{"time"})}
+\item{ninputs}{the number of input columns. (Default: 0)}
\item{Ts}{sampling interval (Default: 1)}
-\item{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})}
-
-\item{tUnit}{Time Unit (Default: "seconds")}
+\item{unit}{Time Unit (Default: "seconds")}
\item{...}{additional arguments to be passed to the \code{\link[utils]{read.table}} function}
}
@@ -42,17 +35,13 @@ Read the contents of an file in table format into a \code{idframe} object.
The \code{read.table.idframe} function uses the \code{\link[utils]{read.table}} function,
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.
}
\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}}
diff --git a/man/read.xls.idframe.Rd b/man/read.xls.idframe.Rd
index 2404b10..99ebbe8 100644
--- a/man/read.xls.idframe.Rd
+++ b/man/read.xls.idframe.Rd
@@ -4,30 +4,19 @@
\alias{read.xls.idframe}
\title{Read the contents of a worksheet into a idframe object}
\usage{
-read.xls.idframe(file, sheetName, header = TRUE, ninputs = NULL,
- type = c("time", "freq")[1], Ts = 1, freqData = FALSE, tUnit = "time",
- ...)
+read.xls.idframe(file, sheetName, header = TRUE, ninputs = 0, Ts = 1,
+ unit = c("seconds", "minutes", "hours", "days", "hours")[1], ...)
}
\arguments{
\item{file}{the path to the file to read}
\item{sheetName}{a character string with the sheet name}
-\item{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})}
-
-\item{ninputs}{the number of input columns. (Default: \code{NULL})}
-
-\item{type}{indicates the domain of the data (Default:\code{"time"})}
+\item{ninputs}{the number of input columns. (Default: 0)}
\item{Ts}{sampling interval (Default: 1)}
-\item{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})}
-
-\item{tUnit}{Time Unit (Default: "seconds")}
+\item{unit}{Time Unit (Default: "seconds")}
\item{...}{additional arguments to be passed to the \code{\link[xlsx]{read.xlsx2}} function}
}
@@ -42,11 +31,6 @@ The \code{read.xlsx.idframe} function uses the \code{\link[xlsx]{read.xlsx2}} fu
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).
}
@@ -56,7 +40,7 @@ dataMatrix <- data.frame(matrix(rnorm(1000),ncol=5))
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}}