Skip to content

Commit

Permalink
fix: Allow quoted column names in pull()
Browse files Browse the repository at this point in the history
Fixes #15
  • Loading branch information
nathaneastwood committed May 5, 2020
1 parent 81184ba commit 81091ea
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: poorman
Type: Package
Title: A Poor Man's Base R Copy of 'dplyr' Verbs
Version: 0.1.11.10
Version: 0.1.11.11
Authors@R: person("Nathan", "Eastwood", "", "[email protected]",
role = c("aut", "cre"))
Maintainer: Nathan Eastwood <[email protected]>
Expand Down
3 changes: 2 additions & 1 deletion R/pull.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
#' mtcars %>% pull(-1)
#' mtcars %>% pull(1)
#' mtcars %>% pull(cyl)
#' mtcars %>% pull("cyl")
#'
#' @export
pull <- function(.data, var = -1) {
var <- deparse(substitute(var))
var <- deparse_var(var)
col_names <- colnames(.data)
if (!(var %in% col_names) & grepl("^[[:digit:]]+L|[[:digit:]]", var)) {
var <- as.integer(gsub("L", "", var))
Expand Down
8 changes: 7 additions & 1 deletion inst/tinytest/test_pull.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ expect_error(
expect_equal(
mtcars %>% pull(mpg),
mtcars[, "mpg"],
info = "Test pulling a single column"
info = "Test pulling a single nse column"
)

expect_equal(
mtcars %>% pull("mpg"),
mtcars[, "mpg"],
info = "Test pulling a single quoted column"
)

expect_equal(
Expand Down
1 change: 1 addition & 0 deletions man/pull.Rd

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

0 comments on commit 81091ea

Please sign in to comment.