Skip to content

Commit

Permalink
add count2
Browse files Browse the repository at this point in the history
  • Loading branch information
vbfelix committed May 8, 2024
1 parent f19584a commit b9a49b9
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 1 deletion.
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.13.1
Version: 3.14.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(count2)
export(count_na)
export(cut_by_quantile)
export(dttm_diff)
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.14.0

**Additions**

- count2

## relper 3.13.1

**Additions**
Expand Down
27 changes: 27 additions & 0 deletions R/count2.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#' Compute the frequency of counts, giving a group variable
#'
#' @description It counts the frequency of the counts, gibing a initial frequency count of the number of occurrences of each group size.
#'
#' @eval arg_df("df")
#' @eval arg_df_var("grp_var","")

#' @return A data.frame
#'
#' @export
#'
#' @examples
#'
#' count2(mtcars,cyl)
#'


count2 <- function(df,grp_var){

stopifnot(is.data.frame(df))

df %>%
dplyr::count({{grp_var}}) %>%
dplyr::count(n)

}

24 changes: 24 additions & 0 deletions man/count2.Rd

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

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

# count2

The goal of `count2` is to count the number of observations, giving a initial count.

```{r count2}
count2(mtcars,cyl)
```

# count_na

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

0 comments on commit b9a49b9

Please sign in to comment.