Skip to content

Commit

Permalink
Merge branch 'release-0.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyuchen committed Feb 22, 2017
2 parents 138e8e9 + 47c05fa commit cfd1298
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
export("%>%")
export(check_missing)
export(check_missing_)
export(ifelse_routine)
export(ifelse_routine_)
export(grp_routine)
export(grp_routine_)
export(ind_to_char)
export(ind_to_char_)
export(pct_routine)
Expand Down
12 changes: 6 additions & 6 deletions R/ifelse_routine.R → R/grp_routine.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Mutate a character/factor based on conditions.
#'
#' \code{ifelse_routine} functions like a serious of nested \code{ifelse} where
#' \code{grp_routine} functions like a serious of nested \code{ifelse} where
#' a series of conditions are evaluated and different values are assigned based
#' on those conditions.
#'
Expand All @@ -11,15 +11,15 @@
#' @inheritParams ind_to_char
#'
#' @export
#' @example /examples/ifelse_routine_ex.R
ifelse_routine <- function(data, col, ..., ret_factor = FALSE) {
ifelse_routine_(data, col, .dots = lazyeval::lazy_dots(...),
#' @example /examples/grp_routine_ex.R
grp_routine <- function(data, col, ..., ret_factor = FALSE) {
grp_routine_(data, col, .dots = lazyeval::lazy_dots(...),
ret_factor = ret_factor)
}

#' @describeIn ifelse_routine SE version of ifelse_routine.
#' @describeIn grp_routine SE version of grp_routine.
#' @export
ifelse_routine_ <- function(data, col, ..., .dots,
grp_routine_ <- function(data, col, ..., .dots,
ret_factor = FALSE) {
conds <- lazyeval::all_dots(.dots, ..., all_named = TRUE)

Expand Down
6 changes: 3 additions & 3 deletions examples/ifelse_routine_ex.R → examples/grp_routine_ex.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ df <- data.frame(v1 = letters[1:5], v2 = 1:5)
df

# By default, it creates new groups
ifelse_routine(df, "group",
grp_routine(df, "group",
first = v1 %in% c("a", "b"),
second = v2 == 3,
third = v2 >= 4)

# Gives a warning when the groups are not collectively exhaustive
ifelse_routine(df, "group",
grp_routine(df, "group",
first = v1 %in% c("a", "b"),
second = v2 == 3,
third = v2 > 4)


# SE version
ifelse_routine_(df, "group",
grp_routine_(df, "group",
"first" = ~ v1 %in% c("a", "b"),
"second" = ~ v2 == 3,
.dots = setNames(list(~ v2 > 4), "third"))
22 changes: 11 additions & 11 deletions man/ifelse_routine.Rd → man/grp_routine.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/ind_to_char.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cfd1298

Please sign in to comment.