Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

describe_class

Describe the class(es) of an object


Description

Describe the class(es) of an object

Usage

describe_class(x, strict_description = TRUE)

## S3 method for class 'factor'
describe_class(x, strict_description = TRUE)

## Default S3 method:
describe_class(x, strict_description = TRUE)

Arguments

x

The object to describe

strict_description

Should differing factor levels be treated as differences for the purposes of identifying mismatches? strict_description = `TRUE` is stricter and factors with different levels will be treated as different classes. FALSE is more lenient: for class comparison purposes, the variable is just a "factor".

Details

For package developers, an S3 generic method can be written for describe_class() for custom classes that may need more definition than the default method. This function is called by compare_df_cols.

Value

A character scalar describing the class(es) of an object where if the scalar will match, columns in a data.frame (or similar object) should bind together without issue.

Methods (by class)

  • factor: Describe factors with their levels and if they are ordered.

  • default: List all classes of an object.

See Also

Other Data frame type comparison: compare_df_cols_same(), compare_df_cols()

Examples

describe_class(1)
describe_class(factor("A"))
describe_class(ordered(c("A", "B")))
describe_class(ordered(c("A", "B")), strict_description=FALSE)

janitor

Simple Tools for Examining and Cleaning Dirty Data

v2.1.0
MIT + file LICENSE
Authors
Sam Firke [aut, cre], Bill Denney [ctb], Chris Haid [ctb], Ryan Knight [ctb], Malte Grosser [ctb], Jonathan Zadra [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.