Skip to content

Commit

Permalink
export additional utility functions (tidyverse#1864)
Browse files Browse the repository at this point in the history
  • Loading branch information
javierluraschi authored and hadley committed May 31, 2016
1 parent c904113 commit 9f1b19e
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 5 deletions.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ S3method(union_all,default)
S3method(union_all,tbl_lazy)
S3method(unique,sql)
export("%>%")
export(add_op_single)
export(add_row)
export(add_rownames)
export(all_equal)
Expand Down Expand Up @@ -404,6 +405,7 @@ export(n)
export(n_distinct)
export(n_groups)
export(na_if)
export(named_commas)
export(near)
export(nth)
export(ntile)
Expand Down Expand Up @@ -467,6 +469,7 @@ export(sql_subquery)
export(sql_translate_env)
export(sql_translator)
export(sql_variant)
export(sql_vector)
export(src)
export(src_desc)
export(src_df)
Expand Down
7 changes: 7 additions & 0 deletions R/lazy-ops.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ op_single <- function(name, x, dots = list(), args = list()) {
)
}

#' @export
#' @rdname lazy_ops
add_op_single <- function(name, .data, dots = list(), args = list()) {
.data$ops <- op_single(name, x = .data$ops, dots = dots, args = args)
.data
}

#' @export
print.op_single <- function(x, ...) {
print(x$x)
Expand Down
2 changes: 2 additions & 0 deletions R/sql-escape.r
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ escape.list <- function(x, parens = TRUE, collapse = ", ", con = NULL) {
sql_vector(pieces, parens, collapse)
}

#' @export
#' @rdname sql
sql_vector <- function(x, parens = NA, collapse = " ", con = NULL) {
if (is.na(parens)) {
parens <- length(x) > 1L
Expand Down
5 changes: 0 additions & 5 deletions R/tbl-lazy.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ print.tbl_lazy <- function(x, ...) {

# Single table methods ----------------------------------------------------

add_op_single <- function(name, .data, dots = list(), args = list()) {
.data$ops <- op_single(name, x = .data$ops, dots = dots, args = args)
.data
}

#' @export
filter_.tbl_lazy <- function(.data, ..., .dots) {
dots <- lazyeval::all_dots(.dots, ...)
Expand Down
4 changes: 4 additions & 0 deletions R/utils.r
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ deparse_all <- function(x) {
vapply(x, deparse2, FUN.VALUE = character(1))
}

#' Provides comma-separated string out ot the parameters
#' @export
#' @keywords internal
#' @param ... Arguments to be constructed into the string
named_commas <- function(...) {
x <- c(...)
if (is.null(names(x))) {
Expand Down
3 changes: 3 additions & 0 deletions man/lazy_ops.Rd

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

16 changes: 16 additions & 0 deletions man/named_commas.Rd

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

3 changes: 3 additions & 0 deletions man/sql.Rd

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

0 comments on commit 9f1b19e

Please sign in to comment.