summaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorSuraj Yerramilli2015-01-29 19:23:21 +0530
committerSuraj Yerramilli2015-01-29 19:23:21 +0530
commit27d4517777cac4ac7409a2c28728a1f8105dcda8 (patch)
tree2432cfe053987223587b43ac808468b79afb8179 /R
parenta40960ddec1b0d649f48806dea18f6506b269374 (diff)
downloadSysID-R-code-27d4517777cac4ac7409a2c28728a1f8105dcda8.tar.gz
SysID-R-code-27d4517777cac4ac7409a2c28728a1f8105dcda8.tar.bz2
SysID-R-code-27d4517777cac4ac7409a2c28728a1f8105dcda8.zip
added documentation for the readxls.idframe function
Diffstat (limited to 'R')
-rw-r--r--R/readData.R45
1 files changed, 39 insertions, 6 deletions
diff --git a/R/readData.R b/R/readData.R
index 704223c..910bc94 100644
--- a/R/readData.R
+++ b/R/readData.R
@@ -1,5 +1,5 @@
# Reading data from dataframes
-readData.idframe <- function(data,ninputs=1,type=c("time","freq")[1],
+read.idframe <- function(data,ninputs=1,type=c("time","freq")[1],
Ts = 1,freqData=FALSE){
if((type=="freq") && (freqData)){
@@ -23,27 +23,60 @@ readData.idframe <- function(data,ninputs=1,type=c("time","freq")[1],
}
# Reading from table-formatted files
-read.idframe <- function(file,header=TRUE,sep=",",ninputs=1,
+readtab.idframe <- function(file,header=TRUE,sep=",",ninputs=1,
type=c("time","freq")[1],Ts = 1,freqData=FALSE,...){
# Read from file (default: csv file)
dat <- read.table(file=file,header=header,sep=sep,...)
# read from dataframe and return idframe object
- out <- readData.idframe(data,ninputs=ninputs,type=type,Ts = Ts,freqData=freqData)
+ out <- read.idframe(data,ninputs=ninputs,type=type,Ts = Ts,freqData=freqData)
return(out)
}
-# Reading from excel files
+#' Read the contents of a worksheet into a idframe object
+#'
+#' Read the contents of an excel worksheet into a \code{idframe} object.
+#'
+#' @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: 1)
+#' @param type ndicates 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 ... additional arguments to be passed to the \code{\link[xlsx]{read.xlsx2}} function
+#'
+#' @details
+#'
+#' The \code{readxlsx.idframe} function uses the \code{\link[xlsx]{read.xlsx2}} function,
+#' 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).
+#'
+#' @return an idframe object
+#' @export
+#' @seealso \code{\link[xlsx]{read.xlsx2}}
readxls.idframe <- function(file,sheetName,header=TRUE,ninputs=1,
type=c("time","freq")[1],Ts = 1,freqData=FALSE,...){
require(xlsx)
- # Read from file (default: csv file)
+ # Read from file into an R data.frame
dat <- read.xlsx2(file=file,sheetName=sheetName,header=header,...)
# read from dataframe and return idframe object
- out <- readData.idframe(data,ninputs=ninputs,type=type,Ts = Ts,freqData=freqData)
+ out <- read.idframe(data,ninputs=ninputs,type=type,Ts = Ts,freqData=freqData)
return(out)
} \ No newline at end of file