diff options
author | Suraj Yerramilli | 2015-08-25 10:08:50 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2015-08-25 10:08:50 +0530 |
commit | 90e2f57bd10a8f55cea07ce117635e3bd39765e6 (patch) | |
tree | db9a5b3117cca51f63d4f6266014b615dd3429f7 /R | |
parent | adbc35a68f59ea37c6e30ab539db416995738104 (diff) | |
download | SysID-R-code-90e2f57bd10a8f55cea07ce117635e3bd39765e6.tar.gz SysID-R-code-90e2f57bd10a8f55cea07ce117635e3bd39765e6.tar.bz2 SysID-R-code-90e2f57bd10a8f55cea07ce117635e3bd39765e6.zip |
Read from odf files functionality and updated documentation
Diffstat (limited to 'R')
-rw-r--r-- | R/readData.R | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/R/readData.R b/R/readData.R index 372013a..6729a1b 100644 --- a/R/readData.R +++ b/R/readData.R @@ -78,6 +78,8 @@ read.table.idframe <- function(file,header=TRUE,sep=",",ninputs=0, #' #' @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. #' @param ninputs the number of input columns. (Default: 0) #' @param Ts sampling interval (Default: 1) #' @param unit Time Unit (Default: "seconds") @@ -117,4 +119,44 @@ read.xls.idframe <- function(file,sheetName,header=TRUE,ninputs=0, # read from dataframe and return idframe object out <- read.idframe(dat,ninputs=ninputs,Ts = Ts,unit=unit) return(out) +} + +#' Reading from .odf documents +#' +#' Read the contents of an a .odf document 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. +#' @param ninputs the number of input columns. (Default: 0) +#' @param Ts sampling interval (Default: 1) +#' @param unit Time Unit (Default: "seconds") +#' @param ... additional arguments to be passed to the \code{\link[xlsx]{read.xlsx2}} function +#' +#' @details +#' +#' The \code{read.odf.idframe} function uses the \code{\link[gnumeric]{read.gnumeric.sheet}} function, +#' provided by the \pkg{xlsx} package, to read data from a .odf file and then calls the +#' \code{\link{read.idframe}} function to read the data into a idframe object +#' +#' @return an idframe object +#' +#' @seealso \code{\link[xlsx]{read.xlsx2}} +#' @export +read.odf.idframe <- function(file,sheetName,header=TRUE,ninputs=0, + Ts = 1,unit=c("seconds","minutes","hours", + "days")[1],...){ + + require(gnumeric) + + # Read from file into an R data.frame + dat <- read.gnumeric.sheet(file=file,sheet.name=sheetName, + head=header,...) + l <- as.list(dat) + dat <- as.data.frame(sapply(l,as.numeric)) + + # read from dataframe and return idframe object + out <- read.idframe(dat,ninputs=ninputs,Ts = Ts,unit=unit) + return(out) }
\ No newline at end of file |