diff util.R @ 1:dbcf9bc275e3 draft

planemo upload commit 063e049d569aeb45e1008cbf044f2dad850eca3d-dirty
author stevecassidy
date Wed, 07 Dec 2016 19:10:51 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util.R	Wed Dec 07 19:10:51 2016 -0500
@@ -0,0 +1,17 @@
+assp_to_tsv <- function(assp, outfile) {
+
+    # convert to a dataframe, need to add one column at a time
+    result <- data.frame(assp[1])
+    if (length(attr(assp,'names'))>1) {
+        for(idx in seq(2,length(attr(assp,'names')))) {
+            result <- cbind(result, assp[idx])
+        }
+    }
+    # add a column of timestamps
+    start <- attr(assp, 'startTime')
+    rate <- attr(assp, 'sampleRate')
+    time <- seq(start, by=1/rate, length.out=nrow(result))
+    result <- cbind(time, result)
+
+    write.table(result, file=outfile, sep="\t", quote=F, row.names=F, col.names=T, append=F)
+}