Skip to contents

This function takes a data frame and computes the count and percentage of each value across specified columns. It also calculates the weighted mean and standard deviation for each variable. The output is a summary data frame useful for analyzing distributions of ordinal or Likert-type scales.

Create a count table with percentages, mean, and standard deviation. This function takes a data frame, computes summary statistics like counts, percentages, means, and standard deviations for each unique value in the selected columns.

Usage

counting(df1, cols)

counting(df1, cols)

Arguments

df1

A data frame containing the data to be processed.

cols

A vector of column names to be included in the calculation.

Value

A data frame in wide format containing:

  • Counts of each value per variable

  • Percentages of each value per variable

  • Weighted mean

  • Weighted standard deviation

A data frame with computed statistics, including counts, percentages, means, and standard deviations. df1 <- data.frame(A = c(-1, -1, -1, 0, -1), B = c(-1, 1, 0, -1, 1)), C = c(0, 0, 1, 0, -1), D = c(0, -1, 1, 1, 1), E = c(1, 1, 0, -1, -1)) counting(df1, cols = c('A', 'B', 'C', 'D', 'E'))

Examples