This function calculates and summarizes the counts and percentages of non-missing values for a specified variable, grouped by another variable. It provides formatted output for integration into summary tables.
add_by_n_noNA(data, variable, by, tbl, ...)A data frame containing the dataset to analyze.
A character string specifying the target variable for which missing data statistics will be computed.
A character string specifying the grouping variable. The data will be grouped by this variable before calculating the statistics.
Not used in the current implementation but retained for compatibility with the gtsummary framework.
Additional arguments (not used in the current implementation).
A data frame in wide format, where each row represents a group (as defined by by), and columns
include statistics for the target variable (variable) in a formatted string.
The function performs the following steps:
Groups the data by the variable specified in by.
Computes the number of non-missing values (nb) for the specified variable.
Renames and formats the output columns for clarity and readability.
Converts the data into a wide format suitable for integration into summary tables, with calculated statistics included in formatted strings.
The output is designed for use with summary tools, such as gtsummary, to display detailed missing
data statistics alongside descriptive statistics.