msberends / cleaner

Fast and Easy Data Cleaning (in R)
https://msberends.github.io/cleaner
31 stars 2 forks source link

do not print the cum count in freq() #1

Open jukkiebah opened 2 years ago

jukkiebah commented 2 years ago

hai

is it possible to print frequency tables using the freq() function, without a cum count column?

thanks

msberends commented 2 years ago

Hi @jukkiebah,

freq() is not part of the AMR package, it is part of the cleaner package so I moved the issue here.

What is the reason you would like to omit the cumulative count column? If you want to omit it for reporting, you can of course use base R or the dplyr package to remove it:

library(dplyr)
library(cleaner)

starwars %>%
  freq(gender)
#> Frequency table 
#> 
#> Class:      character
#> Length:     87
#> Available:  83 (95.40%, NA: 4 = 4.60%)
#> Unique:     2
#> 
#> Shortest:   8
#> Longest:    9
#> 
#>      Item           Count    Percent    Cum. Count    Cum. Percent
#> ---  -----------  -------  ---------  ------------  --------------
#> 1    masculine         66     79.52%            66          79.52%
#> 2    feminine          17     20.48%            83         100.00%

starwars %>%
  freq(gender) %>%
  select(-cum_count)
#>        item count   percent cum_percent
#> 1 masculine    66 0.7951807   0.7951807
#> 2  feminine    17 0.2048193   1.0000000

This will remove the nice printing structure, since the function is built around the requirement of the cum_count and cum_percent columns. So I'm curious what the win would be to remove them 🙂

jukkiebah commented 2 years ago

Ok Thanks That's not want i want indeed. Ill just do with all the columns then. Thanks