Mercurial > repos > stevecassidy > wrassp
comparison util.R @ 1:dbcf9bc275e3 draft
planemo upload commit 063e049d569aeb45e1008cbf044f2dad850eca3d-dirty
| author | stevecassidy |
|---|---|
| date | Wed, 07 Dec 2016 19:10:51 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:6d6dc275b107 | 1:dbcf9bc275e3 |
|---|---|
| 1 assp_to_tsv <- function(assp, outfile) { | |
| 2 | |
| 3 # convert to a dataframe, need to add one column at a time | |
| 4 result <- data.frame(assp[1]) | |
| 5 if (length(attr(assp,'names'))>1) { | |
| 6 for(idx in seq(2,length(attr(assp,'names')))) { | |
| 7 result <- cbind(result, assp[idx]) | |
| 8 } | |
| 9 } | |
| 10 # add a column of timestamps | |
| 11 start <- attr(assp, 'startTime') | |
| 12 rate <- attr(assp, 'sampleRate') | |
| 13 time <- seq(start, by=1/rate, length.out=nrow(result)) | |
| 14 result <- cbind(time, result) | |
| 15 | |
| 16 write.table(result, file=outfile, sep="\t", quote=F, row.names=F, col.names=T, append=F) | |
| 17 } |
