Skip to content

Commit

Permalink
Merge pull request #602 from ropensci/develop
Browse files Browse the repository at this point in the history
Develop to master
  • Loading branch information
elinw committed Jul 5, 2020
2 parents b8be860 + 18fa326 commit db89820
Show file tree
Hide file tree
Showing 20 changed files with 230 additions and 108 deletions.
17 changes: 13 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: skimr
Title: Compact and Flexible Summaries of Data
Version: 2.1.1
Version: 2.1.2
Authors@R:
c(person(given = "Elin",
family = "Waring",
Expand Down Expand Up @@ -83,8 +83,16 @@ Authors@R:
person(given = "Daniel",
family = "Possenriede",
role = "ctb",
email = "possenriede@gmail.com"))
Description: A simple to use summary function that can be used with pipes
email = "possenriede@gmail.com"),
person(given = "David",
family = "Zimmermann",
role = "ctb",
email = "david_j_zimmermann@hotmail.com"),
person(given = "Kyle",
family = "Butts",
role ="ctb",
email = ""))
Description: A simple to use summary function that can be used buttskyle96@gmail.comwith pipes
and displays nicely in the console. The default summary statistics may
be modified by the user as can the default formatting. Support for
data frames and vectors is included, and users can implement their own
Expand Down Expand Up @@ -117,6 +125,7 @@ Imports:
Suggests:
covr,
extrafont,
lubridate,
rmarkdown,
sf,
testthat (>= 2.0.0)
Expand All @@ -125,7 +134,7 @@ VignetteBuilder:
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.0.2
RoxygenNote: 7.1.1
Collate:
'deprecated.R'
'dplyr.R'
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
S3method(get_skimmers,AsIs)
S3method(get_skimmers,Date)
S3method(get_skimmers,POSIXct)
S3method(get_skimmers,Timespan)
S3method(get_skimmers,character)
S3method(get_skimmers,complex)
S3method(get_skimmers,default)
Expand Down
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# skimr 2.1.2

### MINOR IMPROVEMENTS

* Add support for lubridate Timespan objects.
* Improvements to Supporting Additional Objects vignette.

### BUG FIXES

* Update package to work with new version of `knitr`.

# skimr 2.1.1 (2020-04-15)

### MINOR IMPROVEMENTS
Expand Down
7 changes: 7 additions & 0 deletions R/get_skimmers.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ get_skimmers.difftime <- function(column) {
modify_default_skimmers("Date", new_skim_type = "difftime")
}

#' @describeIn get_skimmers Summary functions for `Timespan` columns: [min()],
#' [max()], [median()] and [n_unique()].
#' @export
get_skimmers.Timespan <- function(column) {
modify_default_skimmers("difftime", new_skim_type = "Timespan")
}

#' @describeIn get_skimmers Summary functions for `ts` columns: [min()],
#' [max()], [median()] and [n_unique()].
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ complete_rate <- function(x) {
#' values using s+ regex.
#' @export
n_whitespace <- function(x) {
whitespace <- grepl("^\\s+", x)
whitespace <- grepl("^\\s+$", x)
sum(whitespace)
}

Expand Down
41 changes: 30 additions & 11 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
],
"@type": "SoftwareSourceCode",
"identifier": "skimr",
"description": "A simple to use summary function that can be used\n with pipes and displays nicely in the console. The default summary\n statistics may be modified by the user as can the default formatting.\n Support for data frames and vectors is included, and users can\n implement their own skim methods for specific object types as\n described in a vignette. Default summaries include support for inline\n spark graphs. Instructions for managing these on specific operating\n systems are given in the \"Using skimr\" vignette and the README.",
"description": "A simple to use summary function that can be used buttskyle96@gmail.comwith pipes\n and displays nicely in the console. The default summary statistics may\n be modified by the user as can the default formatting. Support for\n data frames and vectors is included, and users can implement their own\n skim methods for specific object types as described in a vignette.\n Default summaries include support for inline spark graphs.\n Instructions for managing these on specific operating systems are\n given in the \"Using skimr\" vignette and the README.",
"name": "skimr: Compact and Flexible Summaries of Data",
"codeRepository": "https://github.com/ropensci/skimr",
"issueTracker": "https://github.com/ropensci/skimr/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "2.1",
"version": "2.1.2",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"version": "3.6.1",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 3.6.1 (2019-07-05)",
"runtimePlatform": "R version 4.0.1 (2020-06-06)",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -145,6 +144,17 @@
"givenName": "Daniel",
"familyName": "Possenriede",
"email": "possenriede@gmail.com"
},
{
"@type": "Person",
"givenName": "David",
"familyName": "Zimmermann",
"email": "david_j_zimmermann@hotmail.com"
},
{
"@type": "Person",
"givenName": "Kyle",
"familyName": "Butts"
}
],
"copyrightHolder": [
Expand Down Expand Up @@ -186,6 +196,18 @@
},
"sameAs": "https://CRAN.R-project.org/package=extrafont"
},
{
"@type": "SoftwareApplication",
"identifier": "lubridate",
"name": "lubridate",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=lubridate"
},
{
"@type": "SoftwareApplication",
"identifier": "rmarkdown",
Expand Down Expand Up @@ -415,15 +437,12 @@
],
"releaseNotes": "https://github.com/ropensci/skimr/blob/master/NEWS.md",
"readme": "https://github.com/ropensci/skimr/blob/master/README.md",
"fileSize": "1028.792KB",
"contIntegration": [
"https://travis-ci.org/ropenscilabs/skimr",
"https://codecov.io/gh/ropenscilabs/skimr"
],
"fileSize": "364473.922KB",
"contIntegration": ["https://travis-ci.org/ropensci/skimr", "https://ci.appveyor.com/project/michaelquinn32/skimr", "https://codecov.io/gh/ropensci/skimr"],
"review": {
"@type": "Review",
"url": "https://github.com/ropensci/onboarding/issues/175",
"provider": "http://ropensci.org"
"url": "https://github.com/ropensci/software-review/issues/175",
"provider": "https://ropensci.org"
},
"keywords": [
"unconf17",
Expand Down
6 changes: 6 additions & 0 deletions man/get_skimmers.Rd

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

4 changes: 2 additions & 2 deletions man/mutate.skim_df.Rd

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

6 changes: 3 additions & 3 deletions man/print.Rd

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

4 changes: 2 additions & 2 deletions man/reexports.Rd

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

2 changes: 1 addition & 1 deletion man/sfl.Rd

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

31 changes: 31 additions & 0 deletions tests/testthat/print/knit_print-old_knitr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

| | |
|:------------------------|:----|
|Name |iris |
|Number of rows |150 |
|Number of columns |5 |
|_______________________ | |
|Column type frequency: | |
|factor |1 |
|numeric |4 |
|________________________ | |
|Group variables |None |


**Variable type: factor**

|skim_variable | n_missing| complete_rate|ordered | n_unique|top_counts |
|:-------------|---------:|-------------:|:-------|--------:|:-------------------------|
|Species | 0| 1|FALSE | 3|set: 50, ver: 50, vir: 50 |


**Variable type: numeric**

|skim_variable | n_missing| complete_rate| mean| sd| p0| p25| p50| p75| p100|hist |
|:-------------|---------:|-------------:|----:|----:|---:|---:|----:|---:|----:|:-----|
|Sepal.Length | 0| 1| 5.84| 0.83| 4.3| 5.1| 5.80| 6.4| 7.9|▆▇▇▅▂ |
|Sepal.Width | 0| 1| 3.06| 0.44| 2.0| 2.8| 3.00| 3.3| 4.4|▁▆▇▂▁ |
|Petal.Length | 0| 1| 3.76| 1.77| 1.0| 1.6| 4.35| 5.1| 6.9|▇▁▆▇▂ |
|Petal.Width | 0| 1| 1.20| 0.76| 0.1| 0.3| 1.30| 1.8| 2.5|▇▁▇▅▃ |


12 changes: 12 additions & 0 deletions tests/testthat/print/knit_print-summary-old_knitr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

| | |
|:------------------------|:----|
|Name |iris |
|Number of rows |150 |
|Number of columns |5 |
|_______________________ | |
|Column type frequency: | |
|factor |1 |
|numeric |4 |
|________________________ | |
|Group variables |None |
2 changes: 2 additions & 0 deletions tests/testthat/print/knit_print-summary.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Table: Data summary

| | |
|:------------------------|:----|
|Name |iris |
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/print/knit_print.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

Table: Data summary

| | |
|:------------------------|:----|
|Name |iris |
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-get_skimmers.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test_that("get_default_skimmer_names() has a correct list of defaults", {
names(defaults),
c(
"AsIs", "character", "complex", "Date", "difftime", "factor", "list",
"logical", "numeric", "POSIXct", "ts"
"logical", "numeric", "POSIXct", "Timespan", "ts"
)
)
expect_identical(defaults$AsIs, c("n_unique", "min_length", "max_length"))
Expand All @@ -27,6 +27,7 @@ test_that("get_default_skimmer_names() has a correct list of defaults", {
expect_identical(defaults$complex, c("mean"))
expect_identical(defaults$Date, c("min", "max", "median", "n_unique"))
expect_identical(defaults$difftime, c("min", "max", "median", "n_unique"))
expect_identical(defaults$Timespan, c("min", "max", "median", "n_unique"))
expect_identical(defaults$factor, c("ordered", "n_unique", "top_counts"))
expect_identical(defaults$list, c("n_unique", "min_length", "max_length"))
expect_identical(defaults$logical, c("mean", "count"))
Expand Down
41 changes: 41 additions & 0 deletions tests/testthat/test-skim.R
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,47 @@ test_that("skim returns expected response for difftime vectors", {
expect_identical(input$difftime.n_unique, 9L)
})

test_that("skim returns expected response for lubridate Timespan vectors", {
dt <- tibble::tibble(x = lubridate::duration(1))
input <- skim(dt)

# dimensions
expect_n_rows(input, 1)
expect_n_columns(input, 8)

# classes
expect_is(input, "skim_df")
expect_is(input, "tbl_df")
expect_is(input, "tbl")
expect_is(input, "data.frame")
expect_named(input, c(
"skim_type", "skim_variable", "n_missing", "complete_rate",
"Timespan.min", "Timespan.max", "Timespan.median",
"Timespan.n_unique"
))

# attributes
attrs <- attributes(input)
expect_equal(attrs$data_rows, 1)
expect_equal(attrs$data_cols, 1)
expect_equal(attrs$df_name, "`dt`")
expect_equal(
attrs$skimmers_used,
list(Timespan = c("min", "max", "median", "n_unique"))
)

# values
expect_identical(input$skim_variable, "x")
expect_identical(input$skim_type, "Timespan")
expect_identical(input$n_missing, 0L)
expect_equal(input$complete_rate, 1, tolerance = .001)
expect_identical(input$Timespan.min, 1)
expect_identical(input$Timespan.max, 1)
expect_identical(input$Timespan.median, lubridate::duration(1))
expect_identical(input$Timespan.n_unique, 1L)
})


test_that("skim handles objects with multiple classes", {
dat <- seq(as.Date("2011-07-01"), by = 1, len = 10)
dat[2] <- NA
Expand Down
17 changes: 13 additions & 4 deletions tests/testthat/test-skim_print.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,23 @@ test_that("knit_print produces expected results", {
input <- knit_print(skimmed)
expect_is(input, "knit_asis")
expect_length(input, 1)
expect_matches_file(input, "print/knit_print.txt")
if (packageVersion("knitr") <= "1.28") {
expect_matches_file(input, "print/knit_print-knitr_old.txt")
} else {
expect_matches_file(input, "print/knit_print.txt")
}
})

test_that("knit_print works with skim summaries", {
skimmed <- skim(iris)
summarized <- summary(skimmed)
input <- knitr::knit_print(summarized)

skimmed <- skim(iris)
summarized <- summary(skimmed)
input <- knitr::knit_print(summarized)
if (packageVersion("knitr") <= "1.28") {
expect_matches_file(input, "print/knit_print-summary-knitr_old.txt")
} else {
expect_matches_file(input, "print/knit_print-summary.txt")
}
})

test_that("knit_print appropriately falls back to tibble printing", {
Expand Down

0 comments on commit db89820

Please sign in to comment.