diff options
author | Suraj Yerramilli | 2015-01-19 16:40:54 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2015-01-19 16:40:54 +0530 |
commit | c2b6c8c1598880d27cc2fdd40409e574e8022fe3 (patch) | |
tree | 5c7305d92a261ad7556853a0e8253089099001cc | |
parent | f69cc92eee8038f35f405c246364303a91f22cd2 (diff) | |
download | SysID-R-code-c2b6c8c1598880d27cc2fdd40409e574e8022fe3.tar.gz SysID-R-code-c2b6c8c1598880d27cc2fdd40409e574e8022fe3.tar.bz2 SysID-R-code-c2b6c8c1598880d27cc2fdd40409e574e8022fe3.zip |
Added function to read data from tabular files
-rw-r--r-- | R/readData.R | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/R/readData.R b/R/readData.R new file mode 100644 index 0000000..4893b6f --- /dev/null +++ b/R/readData.R @@ -0,0 +1,23 @@ +# 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,...) + + if((type=="freq") && (freqData)){ + + frequencies <- dat[,1] # the first column must contain frequencies + inputs <- dat[,seq(2,length.out=ninputs,by=1)] + outputs <- dat[,seq((ninputs+1),dim(dat)[2],by=1)] + + out <- idframe(output=outputs,input=inputs,type=type,Ts=Ts, + frequencies=frequencies) + + } else{ + + inputs <- dat[,1:ninputs] + outputs <- dat[,seq(ninputs,dim(dat)[2],by=1)] + + out <- idframe(output=outputs,input=inputs,type=type,Ts=Ts) + } +}
\ No newline at end of file |