Learn R Programming

inspectdf (version 0.0.2)

inspect_types: Summarise and compare column types in one or two dataframes.

Description

Summarise and compare column types in one or two dataframes.

Usage

inspect_types(df1, df2 = NULL, show_plot = FALSE)

Arguments

df1

A data frame.

df2

An optional second data frame for comparison.

show_plot

(Deprecated) Logical flag indicating whether a plot should be shown. Superseded by the function show_plot() and will be dropped in a future version.

Value

A tibble summarising the count and percentage of different column types for one or a pair of data frames.

Details

When df2 = NULL, a tibble is returned with the columns

  • type character vector containing the column types in df1.

  • cnt integer counts of each type.

  • pcnt the percentage of all columns with each type.

  • col_name the names of columns with each type.

When a second data frame df2 is specified, column type summaries are tabulated for both data frames to enable comparison of contents. The resulting tibble has the columns

  • type character vector containing the column types in df1 and df2.

  • cnt_1, cnt_2 pair of integer columns containing counts of each type - in each of df1 and df2.

  • pcnt_1, pcnt_2 pair of columns containing the percentage of columns with each type - the data frame name are appended.

Examples

Run this code
# NOT RUN {
data("starwars", package = "dplyr")
# get tibble of column types for the starwars data
inspect_types(starwars)
# compare two data frames
inspect_types(starwars, starwars[, -1])
# }

Run the code above in your browser using DataLab