Browse files

Merge branch 'master' of github.com:halpo/dostats

Conflicts:
	DESCRIPTION
	R/wargs.R
  • Loading branch information...
2 parents 5690605 + 8227a57 commit 9bbe7730e4b726c3e5da52c413d6af71287d8ff9 @halpo committed Jul 23, 2012
Showing with 17 additions and 13 deletions.
  1. +1 −1 DESCRIPTION
  2. +14 −0 R/capply.R
  3. +1 −1 R/hdf.R
  4. +1 −10 R/utils.R
  5. +0 −1 R/wargs.R
View
2 DESCRIPTION
@@ -26,4 +26,4 @@ Collate:
'formula.R'
'hdf.R'
'pval.R'
- 'utils.R'
+ 'utils.R'
View
14 R/capply.R
@@ -0,0 +1,14 @@
+
+
+#' Conditional Apply
+#'
+#' A wrapper for \code{ifelse(test(x), fun(x, ...), x)}
+#'
+#' @param test a test that returns a logical
+#' @param fun to apply
+#' @param x data to apply fun to.
+#'
+#'
+capply <- function(test, x, fun, ...){
+ ifelse(Map(test, x), fun(x, ...), x)
+}
View
2 R/hdf.R
@@ -170,7 +170,7 @@ recombine.hdf <- function(x, ri){
make_ppath <- function(id, header) {
if(length(id) > 1) return(llply(id, make_ppath, header))
par <- trace_parents(header, id)
- reverse(header[c(id, par), 'position'])
+ rev(header[c(id, par), 'position'])
}
copy_names <- function(x, header) {
by.parent <- dlply(header, 'parent', I)
View
11 R/utils.R
@@ -22,7 +22,7 @@
# dostats. If not, see http://www.gnu.org/licenses/.
#
}###############################################################################
-{## Utilities
+
first <- wargs(head, n=1)
last <- wargs(tail, n=1)
@@ -84,19 +84,10 @@ me<- function(){
}
-#' reverse the order of a vector
-#' @param x any vector
-#' @export
-reverse <- function(x){
- x[seq(from=length(x), to=1)]
-}
-
#' Fill vector to length with a specified value
#'
#' @export
fill_v <- function(x, l=length(x), with=last(x), after=length(x)){
stopifnot(length(x) <= l)
append(x, rep(with, l-length(x)), after=after)
}
-
-}
View
1 R/wargs.R
@@ -76,4 +76,3 @@ redirf <- function(f, envir=parent.frame()){
args <- formals(f)
wrap_function(symb, args, envir)
}
-

0 comments on commit 9bbe773

Please sign in to comment.