-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Concluded development work, added some unit tests and improved docume…
…ntation and namespace management.
- Loading branch information
Showing
6 changed files
with
76 additions
and
27 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
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
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 |
---|---|---|
@@ -1,21 +1,26 @@ | ||
test_that("standard summary returns correct results", { | ||
# Create a test data frame | ||
df <- data.frame( | ||
x = c(1, 2, 3, 4, 5), | ||
y = c(6, 7, 8, 9, 10) | ||
groups = c("a","a","a","b","c"), | ||
var1 = c(1, 2, 3, 4, 5), | ||
var2 = c(6, 7, NA, 9, 10) | ||
) | ||
|
||
# Call the standard summary function | ||
result <- standard_summary(df) | ||
|
||
|
||
# Calculate standard summary statistics for var1 and var2 | ||
result <- starwars %>% | ||
filter(!is.na(sex)) %>% | ||
group_by(sex) %>% | ||
standard_summary(vars=c("height", "mass","birth_year")) | ||
|
||
# Check if the result is a data frame | ||
expect_is(result, "data.frame") | ||
# Check if the result has the correct number of rows and columns | ||
expect_equal(nrow(result), 2) | ||
expect_equal(ncol(result), 2) | ||
expect_true(is.data.frame(result)) | ||
|
||
# Check if the result has the correct number of rows and columns | ||
expect_equal(nrow(result), 12) | ||
expect_equal(df_n_col(result), 13) | ||
|
||
# Check if the result contains the correct summary statistics | ||
expect_equal(result[1, "x"], 3) | ||
expect_equal(result[2, "y"], 8) | ||
}) | ||
expect_equal(result[1,"min"], 150) | ||
expect_equal(result[2, "med"] , 55) | ||
expect_equal(result[7,"nmiss"],3) | ||
}) |
Empty file.