summaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorSuraj Yerramilli2015-01-19 17:55:24 +0530
committerSuraj Yerramilli2015-01-19 17:55:24 +0530
commita86211c3abe75ca95d80753362800b207fa8ceec (patch)
tree0893e224f0b0ec50dca8c279606a6a9f285b9e40 /R
parentc2b6c8c1598880d27cc2fdd40409e574e8022fe3 (diff)
downloadSysID-R-code-a86211c3abe75ca95d80753362800b207fa8ceec.tar.gz
SysID-R-code-a86211c3abe75ca95d80753362800b207fa8ceec.tar.bz2
SysID-R-code-a86211c3abe75ca95d80753362800b207fa8ceec.zip
Added support to read from dataframe objects and excel files
Diffstat (limited to 'R')
-rw-r--r--R/readData.R36
1 files changed, 31 insertions, 5 deletions
diff --git a/R/readData.R b/R/readData.R
index 4893b6f..704223c 100644
--- a/R/readData.R
+++ b/R/readData.R
@@ -1,8 +1,6 @@
-# Reading from table-formatted files
-read.idframe(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,...)
+# Reading data from dataframes
+readData.idframe <- function(data,ninputs=1,type=c("time","freq")[1],
+ Ts = 1,freqData=FALSE){
if((type=="freq") && (freqData)){
@@ -20,4 +18,32 @@ read.idframe(file,header=TRUE,sep=",",ninputs=1,
out <- idframe(output=outputs,input=inputs,type=type,Ts=Ts)
}
+
+ return(out)
+}
+
+# Reading from table-formatted files
+read.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)
+ return(out)
+}
+
+# Reading from excel files
+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)
+ 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)
+ return(out)
} \ No newline at end of file