Skip to content

Commit

Permalink
Merge pull request #40 from vbfelix/count_na
Browse files Browse the repository at this point in the history
increment to 3.12.0
  • Loading branch information
vbfelix authored Mar 20, 2024
2 parents 8436a6a + 28aa76d commit 66d665b
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: relper
Title: Miscellaneous Functions for Data Preparation, Cleaning, and Visualization
Version: 3.11.3
Version: 3.12.0
Authors@R: person("Vinícius", "Félix", email = "vinicius1b7f@gmail.com", role = c("aut", "cre"))
Description: A collection of functions to help with data preparation, cleaning, and visualization. relper offers functions to: transform and format data (e.g., easily apply the percentage), compute metrics (e.g., coefficient of variation), check conditions (e.g., determine if a number is even or odd), supply lovely and varied color palettes (e.g., palettes inspired by TV series and movies), complement ggplot2 (e.g., add an identity line to a scatter plot), manipulate strings (e.g., keep only a type of character). The package's ultimate purpose is to simplify data analysis by providing functions that will shorten some steps.
Depends: R (>= 3.6.0)
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export(calc_mode)
export(calc_peak_density)
export(calc_perc)
export(calc_skewness)
export(count_na)
export(cut_by_quantile)
export(dttm_diff)
export(dttm_vars)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
>
> *These additions transform the package into a comprehensive "Data Insight Toolbox," empowering users to gain deeper insights and perform advanced analyses on their datasets. Additionally, some functions have been renamed for better clarity and consistency.*
## relper 3.12.0

**Additions**

- count_na

## relper 3.11.3

**Additions**
Expand Down
25 changes: 25 additions & 0 deletions R/count_na.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#' Count the number of NA observations
#'
#' @description Count the number of NA observations
#'
#' @eval arg_value("x","")

#' @return A numeric value
#'
#' @export
#'
#' @examples
#'
#' count_na(c(2,2,2))
#'
#' count_na(c(2,2,NA))
#'


count_na <- function(x){

output <- sum(is.na(x),na.rm = TRUE)

return(output)

}
24 changes: 24 additions & 0 deletions man/count_na.Rd

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

21 changes: 21 additions & 0 deletions tests/testthat/test-count_na.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
test_that("Expect equal", {

expect_equal(
object = count_na(1:3),
expected = 0
)
expect_equal(
object = count_na(NA),
expected = 1
)
expect_equal(
object = count_na(letters),
expected = 0
)
expect_equal(
object = count_na(NA_character_),
expected = 1
)

})

9 changes: 3 additions & 6 deletions tests/testthat/test-is_blank.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ test_that("Expect FALSE", {

expect_false(object = is_blank("a"))

})

test_that("Expect error", {
expect_false(object = is_blank(TRUE))

expect_error(object = is_blank(TRUE))

expect_error(object = is_blank(1))
expect_false(object = is_blank(1))

})

12 changes: 12 additions & 0 deletions vignettes/other_functions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ library(dplyr)
library(ggplot2)
```

# count_na

The goal of `count_na` is to count the number of missing observations.

```{r count_na}
count_na(c(2,2,NA))
count_na(c(2,2,2))
```


# cut_by_quantile

The goal of `cut_by_quantile` is to divide a numeric variable by a set of quantiles.
Expand Down

0 comments on commit 66d665b

Please sign in to comment.