diff options
| author | St33v <st33v@woodenspoon.net> | 2013-05-16 19:36:36 +1100 |
|---|---|---|
| committer | St33v <st33v@woodenspoon.net> | 2013-05-16 19:36:36 +1100 |
| commit | ce1fb0f7fd62c41101055d2c34e721c0b54a11fa (patch) | |
| tree | b44f025a600c99939b5a0d11c1353efd756d6303 /file settings and cleanup | |
| parent | 5bdaeca7deca9682afc37bf9e976ceef5e862e38 (diff) | |
Update file settings and cleanup
Added some text file formatting fns and the mighty htail!
Diffstat (limited to 'file settings and cleanup')
| -rw-r--r-- | file settings and cleanup | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/file settings and cleanup b/file settings and cleanup index f62b1ce..7c7e5ba 100644 --- a/file settings and cleanup +++ b/file settings and cleanup @@ -16,6 +16,41 @@ justFile <- function(x) { return(fname) } +####################################################################### +# heading - take a string and print it out with underline +# Useful for formatting output text files +# +headingFunc <- function(string, ul='=', caps=T){ + if(length(string) != 1) string <- 'Error in headingFunc' + if(class(string) != 'character') string <- as.character(string) + if(caps) string <- toupper(string) + cat('\n', string, '\n', sep='') + reps <- floor(nchar(string) / nchar(ul)) + filler <- substr(ul, 1, (nchar(string) %% nchar(ul))) + cat(rep(ul, reps), filler, '\n\n', sep='') +} + +############ handy for debugging ##################################### +####################################################################### +# unWarn - set options() +unWarn <- function() options( warn = -1) +####################################################################### +# Warn - set options() +warn <- function() options( warn = 0) + +####################################################################### +# sort of created by mistake when Joe typed htail +# prints the head and tail of a datframe or array. +# -- separates head from tail with a row of '...' (can be buggy) +# you can pass in lengths for head and tail if you want to. +htail <- function(x, min_obs=15, ...){ + if(dim(x)[1] < min_obs) return(x) + hd <- head(x, ...) + tl <- tail(x, ...) + dots <- rep('...', ncol(x)) + res <- rbind(hd, '...'=dots, tl) + return(res) +} ####################################################################### # nukem - erase all objects (after asking nicely) |
