observation_count: Get the number of times a row appears in a dataframe

Description Usage Arguments Value See Also Examples

Description

Not to be confused with a total row count of a dataframe (ie 'nrow()'), this is a shortcut for 'group_by_all()' followed by 'count()'.

Usage

1

Arguments

data

A dataframe or tibble.

desc

If TRUE, the output is arranged in descending order. Otherwise it is arranged in ascending order.

Value

Ungrouped dataframe with all input columns with the addition of an 'n' column for the count.

See Also

group_by_all,count,group_by,arrange

Other summary functions: summarize_variables()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
library(tidyverse)
test_data <- 
        tibble(
                Group = sample(c("Apple", "Pear"), size = 10, replace = TRUE),
                A     = sample(c(NA_integer_, 1:3), size = 10, replace = TRUE),
                B     = sample(c(NA_integer_, 4:6), size = 10, replace = TRUE),
                C     = sample(c(NA_real_, seq(from = 6.01, to = 6.09, by = 0.01)), size = 10, replace = TRUE)
        )


summarize_variables(data = test_data,
                    incl_num_calc = FALSE)

summarize_variables(data = test_data,
                    incl_num_calc = TRUE)

summarize_variables(data = test_data,
                    incl_num_calc = TRUE,
                    grouper = Group)

summarize_variables(data = test_data,
                    incl_num_calc = FALSE,
                    grouper = Group)


observation_count(data = test_data)


value_count(data = test_data)
value_count(data = test_data,
            grouper = Group)

meerapatelmd/rubix documentation built on Sept. 5, 2021, 8:30 p.m.