-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
203 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: extdplyr | ||
Type: Package | ||
Title: Data Manipulation Extension Based on 'Dplyr' and 'Tidyr' | ||
Version: 0.1.3 | ||
Title: Data Manipulation Extensions of 'Dplyr' and 'Tidyr' | ||
Version: 0.1.4 | ||
Authors@R: person("Yuchen", "Wang", email = "[email protected]", | ||
role = c("aut", "cre")) | ||
Description: If 'dplyr' is a grammar for data manipulation, 'extdplyr' is like | ||
|
@@ -17,3 +17,5 @@ Imports: | |
tidyr, | ||
lazyeval | ||
RoxygenNote: 6.0.1 | ||
Suggests: testthat, | ||
data.table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#' @importFrom dplyr %>% | ||
#' @importFrom tidyr %>% | ||
#' @export | ||
dplyr::`%>%` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,27 +6,14 @@ | |
## R CMD check results | ||
There were no ERRORs or WARNINGs. | ||
|
||
win-builder check has 1 note: | ||
There was 1 NOTES on win-builder: | ||
|
||
``` | ||
New submission | ||
``` | ||
|
||
* checking CRAN incoming feasibility ... NOTE | ||
Maintainer: 'Yuchen Wang <[email protected]>' | ||
Fixed 2 notes in previous submission. | ||
|
||
``` | ||
Possibly mis-spelled words in DESCRIPTION: | ||
dplyr (3:45, 7:18, 8:35, 8:63, 10:61) | ||
extdplyr (7:62, 8:44) | ||
tidyr (3:55, 9:6) | ||
Days since last update: 4 | ||
``` | ||
|
||
Fixed description file for title case and single quotes. | ||
|
||
``` | ||
Non-standard file/directory found at top level: | ||
'examples' | ||
``` | ||
I'm sorry for the constant update. A problem was found that could cause `ind_to_char_` to fail when data are grouped as a `grouped_df` object from `dplyr`. This has been fixed in the latest version, and several tests are added to make sure the functions work with various data structures, including `tbl_df`, `grouped_df` and `data.table`. | ||
|
||
This is fixed by adding the folder to `.Rbuildignore`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
library(testthat) | ||
library(extdplyr) | ||
|
||
test_check("extdplyr") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
library(extdplyr) | ||
context("ind_to_char_ and grp_routine_") | ||
|
||
test_that("ind_to_char_ works with regular data.frame", { | ||
df <- data.frame(x = 1:5, y = factor(c(letters[1:5]))) | ||
ind_df <- as.data.frame(model.matrix(~ x + y - 1, df)) | ||
|
||
# Using SE | ||
df_ret <- ind_to_char_(ind_df, col = "new_y", | ||
from = c("ya", "yb", "yc", "yd", "ye")) | ||
|
||
expect_equal(ncol(df_ret), 2) | ||
expect_equal(df_ret[['new_y']], c("ya", "yb", "yc", "yd", "ye")) | ||
|
||
df_ret2 <- ind_to_char_(ind_df, col = "new_y", | ||
from = c("ya", "yb", "yc", "yd", "ye"), | ||
remove = FALSE) | ||
expect_equal(ncol(df_ret2), 7) | ||
expect_equal(df_ret2[["new_y"]], c("ya", "yb", "yc", "yd", "ye")) | ||
}) | ||
|
||
|
||
test_that("ind_to_char_ works with non-integer indicators", { | ||
df <- data.frame(integer_ind = c(1L, 0L, 0L, 0L, 0L, 0L), | ||
logcal_ind = c(FALSE, TRUE, FALSE, FALSE, FALSE, FALSE), | ||
double_ind = c(0, 0, 2.0, 0, 0, 0), | ||
char_ind = c("FALSE", "FALSE", "F", "TRUE", "T", "FALSE"), | ||
factor_ind = factor(c(1, 1, 1, 1, 1, 0), levels = c(0, 1), | ||
labels = c(TRUE, FALSE)), | ||
stringsAsFactors = FALSE) | ||
|
||
# Using SE | ||
df_ret <- ind_to_char_(df, col = "new_y", from = names(df), remove = FALSE) | ||
|
||
expect_equal(ncol(df_ret), 6) | ||
expect_equal(which(names(df_ret) == "new_y"), 1) | ||
expect_equal(df_ret[['new_y']], | ||
c("integer_ind", "logcal_ind", "double_ind", "char_ind", | ||
"char_ind", "factor_ind")) | ||
|
||
}) | ||
|
||
|
||
|
||
library(dplyr) | ||
test_that("ind_to_char_ works with tbl_df, tbl, data.frame", { | ||
df <- data.frame(x = 1:5, y = factor(c(letters[1:5]))) | ||
ind_df <- as_data_frame(model.matrix(~ x + y - 1, df)) | ||
|
||
# Using SE | ||
df_ret <- ind_to_char_(ind_df, col = "new_y", | ||
from = c("ya", "yb", "yc", "yd", "ye")) | ||
|
||
expect_equal(class(ind_df), class(df_ret)) | ||
expect_equal(ncol(df_ret), 2) | ||
expect_equal(df_ret[['new_y']], c("ya", "yb", "yc", "yd", "ye")) | ||
|
||
df_ret2 <- ind_to_char_(ind_df, col = "new_y", | ||
from = c("ya", "yb", "yc", "yd", "ye"), | ||
remove = FALSE) | ||
|
||
expect_equal(class(ind_df), class(df_ret2)) | ||
expect_equal(ncol(df_ret2), 7) | ||
expect_equal(df_ret2[["new_y"]], c("ya", "yb", "yc", "yd", "ye")) | ||
}) | ||
|
||
|
||
test_that("ind_to_char_ works with grouped_df, tbl_df, tbl, data.frame", { | ||
df <- data.frame(x = 1:5, y = factor(c(letters[1:5]))) | ||
ind_df <- as_data_frame(model.matrix(~ x + y - 1, df)) %>% | ||
group_by(z = x > 3) | ||
|
||
# Using SE | ||
df_ret <- ind_to_char_(ind_df, col = "new_y", | ||
from = c("ya", "yb", "yc", "yd", "ye")) | ||
|
||
expect_equal(class(ind_df), class(df_ret)) | ||
expect_equal(ncol(df_ret), 3) | ||
expect_equal(df_ret[['new_y']], c("ya", "yb", "yc", "yd", "ye")) | ||
|
||
df_ret2 <- ind_to_char_(ind_df, col = "new_y", | ||
from = c("ya", "yb", "yc", "yd", "ye"), | ||
remove = FALSE) | ||
|
||
expect_equal(class(ind_df), class(df_ret2)) | ||
expect_equal(ncol(df_ret2), 8) | ||
expect_equal(df_ret2[["new_y"]], c("ya", "yb", "yc", "yd", "ye")) | ||
}) | ||
|
||
|
||
if (requireNamespace("data.table", quietly = TRUE)) { | ||
test_that("ind_to_char_ works with tbl_df, tbl, data.frame", { | ||
df <- data.frame(x = 1:5, y = factor(c(letters[1:5]))) | ||
ind_df <- data.table::data.table(model.matrix(~ x + y - 1, df)) | ||
|
||
# Using SE | ||
df_ret <- ind_to_char_(ind_df, col = "new_y", | ||
from = c("ya", "yb", "yc", "yd", "ye")) | ||
|
||
expect_equal(class(ind_df), class(df_ret)) | ||
expect_equal(ncol(df_ret), 2) | ||
expect_equal(df_ret[['new_y']], c("ya", "yb", "yc", "yd", "ye")) | ||
|
||
df_ret2 <- ind_to_char_(ind_df, col = "new_y", | ||
from = c("ya", "yb", "yc", "yd", "ye"), | ||
remove = FALSE) | ||
|
||
expect_equal(class(ind_df), class(df_ret2)) | ||
expect_equal(ncol(df_ret2), 7) | ||
expect_equal(df_ret2[["new_y"]], c("ya", "yb", "yc", "yd", "ye")) | ||
}) | ||
} | ||
|
||
|
||
|