average_fre: Average frequency of numbers in a column

View source: R/average_fre.R

average_freR Documentation

Average frequency of numbers in a column

Description

The 'average_fre()' function takes a column in a data frame and calculates the average frequency with which integers are paired with numbers in the first decimal place.

Usage

average_fre(data, variable, group = NULL, decimal_place = 1)

Arguments

data

A data frame

variable

A numeric variable that includes the first decimal place.

group

A second variable used to group the primary variable such that average frequency is calculated separately for each group.

decimal_place

The number of decimal places used for the calculation. The default is set to "1" meaning decimals in the second (hundreds place) and below are discarded.

Details

To calculate average frequency, the number of times each pair (integer and first decimal) occurs is calculated. This number appears once in the numerator for each occurrence. These numbers are summed and divided by n.

For example, for the vector c(1.4, 0.4, 1.4, 2.0) the average frequency is calculated by (2 + 1 + 2 + 1) / 4 = 1.5.

Value

A numeric value or when a group variable is specified a vector of numeric values.

Examples

average_fre(simulated_normal, obs)


josh-mc/fabricated documentation built on April 25, 2022, 1:31 p.m.