Learn R Programming

cld (version 0.0.1)

as_cld: Convert objects to cld_object

Description

Generic function to convert various objects to cld_object format. This is useful when you have CLD results from other packages or custom formats and want to use them with cld's methods.

Usage

as_cld(x, ...)

# S3 method for data.frame as_cld(x, ...)

# S3 method for character as_cld(x, ...)

# S3 method for cld_object as_cld(x, ...)

Value

A cld_object (data frame with class c("cld_object", "data.frame")) containing three columns:

  • group - Character. The names of the groups

  • cld - Character. The compact letter display for each group

  • spaced_cld - Character. A monospaced version of the CLD where spaces are replaced with underscores, useful for maintaining alignment in output

Arguments

x

Object to convert to cld_object

...

Additional arguments passed to methods

Details

The as_cld() function provides a way to convert various formats to the standard cld_object structure. This is particularly useful when:

  • Working with CLD results from other packages

  • Converting custom formats to use cld's print and coercion methods

  • Creating CLD objects programmatically

See Also

  • make_cld() for creating compact letter displays

  • pval_matrix_to_df() for converting p-value matrices

  • cld_methods for other cld_object methods

Other helper functions: pval_matrix_to_df()

Other data conversion functions: pval_matrix_to_df()

Examples

Run this code
# Convert from data frame
df <- data.frame(
  group = c("A", "B", "C"),
  cld = c("a", "b", "b")
)
as_cld(df)

# Convert from named character vector
letters_vec <- c(A = "a", B = "b", C = "b")
as_cld(letters_vec)

Run the code above in your browser using DataLab