Learn R Programming

cld (version 0.0.1)

pval_matrix_to_df: Convert matrix with p-values to data frame

Description

This function converts a matrix of p-values into a data frame with three columns: gr1 (column names), gr2 (row names), and p_values (the p-values). This is particularly useful when you have a symmetric matrix of p-values from pairwise comparisons and need to convert it to a long-format data frame for further analysis or for use with make_cld().

Usage

pval_matrix_to_df(x)

Value

A data frame of class c("pairwise_pval_df", "data.frame") with columns:

  • gr1 - names from the columns of the matrix

  • gr2 - names from the rows of the matrix

  • p_values - the corresponding p-values from the matrix (excluding NA values)

Arguments

x

A numeric matrix containing p-values. If the matrix has no column or row names, they will be assigned sequential numbers. The matrix can be symmetric (with diagonal and upper/lower triangle) or triangular. NA values are removed from the output.

See Also

  • make_cld() for creating compact letter displays from the resulting data frame

  • as_cld() for converting other formats to cld_object

Other helper functions: as_cld()

Other data conversion functions: as_cld()

Examples

Run this code
# Create a matrix of p-values
m <- matrix(c(NA, 0.05, 0.01, 0.05, NA, 0.03, 0.01, 0.03, NA), nrow = 3)
colnames(m) <- c("A", "B", "C")
rownames(m) <- c("A", "B", "C")

# Convert to data frame
cld::pval_matrix_to_df(m)

Run the code above in your browser using DataLab