Skip to content

Commit 7a4f82c

Browse files
committed
Merge pull request #151 from krlmlr/separate-cleanup
Cleanup for separate() and spread()
2 parents 71a0244 + 632fd46 commit 7a4f82c

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252

5353
* `unite()` now removes old columns before adding new (#89, @krlmlr).
5454

55+
* `separate()` now warns if defunct ... argument is used (#151, @krlmlr).
56+
5557
# tidyr 0.3.1
5658

5759
* Fixed bug where attributes of non-gather columns were lost (#104)

R/separate.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ separate <- function(data, col, into, sep = "[^[:alnum:]]+", remove = TRUE,
7171
#' @param convert If \code{TRUE}, will run \code{\link{type.convert}} with
7272
#' \code{as.is = TRUE} on new columns. This is useful if the component
7373
#' columns are integer, numeric or logical.
74-
#' @param ... Other arguments passed on to \code{\link{strsplit}} to control
75-
#' how the regular expression is processed.
74+
#' @param ... Defunct, will be removed in the next version of the package.
7675
#' @keywords internal
7776
#' @export
7877
separate_ <- function(data, col, into, sep = "[^[:alnum:]]+", remove = TRUE,
@@ -87,6 +86,10 @@ separate_.data.frame <- function(data, col, into, sep = "[^[:alnum:]]+",
8786
stopifnot(is.character(col), length(col) == 1)
8887
value <- as.character(data[[col]])
8988

89+
if (length(list(...)) != 0) {
90+
warning("Using ... for passing arguments to strsplit is defunct.")
91+
}
92+
9093
if (is.numeric(sep)) {
9194
l <- strsep(value, sep)
9295
} else if (is.character(sep)) {
@@ -116,9 +119,9 @@ separate_.tbl_df <- function(data, col, into, sep = "[^[:alnum:]]+",
116119
}
117120

118121
#' @export
119-
separate_.tbl_df <- function(data, col, into, sep = "[^[:alnum:]]+",
120-
remove = TRUE, convert = FALSE,
121-
extra = "warn", fill = "warn", ...) {
122+
separate_.grouped_df <- function(data, col, into, sep = "[^[:alnum:]]+",
123+
remove = TRUE, convert = FALSE,
124+
extra = "warn", fill = "warn", ...) {
122125
dplyr::grouped_df(NextMethod(), dplyr::groups(data))
123126
}
124127

R/spread.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ spread_.tbl_df <- function(data, key_col, value_col, fill = NA,
137137
}
138138

139139
#' @export
140-
spread_.tbl_df <- function(data, key_col, value_col, fill = NA,
141-
convert = FALSE, drop = TRUE) {
140+
spread_.grouped_df <- function(data, key_col, value_col, fill = NA,
141+
convert = FALSE, drop = TRUE) {
142142
regroup(data, NextMethod(), except = c(key_col, value_col))
143143
}
144144

man/separate.Rd

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/separate_.Rd

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)