| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/skim.R |
| 3 |
\name{skim} |
| 4 |
\alias{skim} |
| 5 |
\alias{skim_tee} |
| 6 |
\alias{skim_without_charts} |
| 7 |
\title{Skim a data frame, getting useful summary statistics} |
| 8 |
\usage{ |
| 9 |
skim(data, ..., .data_name = NULL) |
| 10 |
|
| 11 |
skim_tee(data, ..., skim_fun = skim) |
| 12 |
|
| 13 |
skim_without_charts(data, ..., .data_name = NULL) |
| 14 |
} |
| 15 |
\arguments{ |
| 16 |
\item{data}{A tibble, or an object that can be coerced into a tibble.} |
| 17 |
|
| 18 |
\item{...}{Columns to select for skimming. When none are provided, the |
| 19 |
default is to skim all columns.} |
| 20 |
|
| 21 |
\item{.data_name}{The name to use for the data. Defaults to the same as data.} |
| 22 |
|
| 23 |
\item{skim_fun}{The skim function used.} |
| 24 |
|
| 25 |
\item{skim}{The skimming function to use in \code{skim_tee()}.} |
| 26 |
} |
| 27 |
\value{ |
| 28 |
A \code{skim_df} object, which also inherits the class(es) of the input |
| 29 |
data. In many ways, the object behaves like a \code{\link[tibble:tibble]{tibble::tibble()}}. |
| 30 |
} |
| 31 |
\description{ |
| 32 |
\code{skim()} is an alternative to \code{\link[=summary]{summary()}}, quickly providing a broad |
| 33 |
overview of a data frame. It handles data of all types, dispatching a |
| 34 |
different set of summary functions based on the types of columns in the data |
| 35 |
frame. |
| 36 |
} |
| 37 |
\details{ |
| 38 |
Each call produces a \code{skim_df}, which is a fundamentally a tibble with a |
| 39 |
special print method. One unusual feature of this data frame is pseudo- |
| 40 |
namespace for columns. \code{skim()} computes statistics by data type, and it |
| 41 |
stores them in the data frame as \verb{<type>.<statistic>}. These types are |
| 42 |
stripped when printing the results. The "base" skimmers (\code{n_missing} and |
| 43 |
\code{complete_rate}) are the only columns that don't follow this behavior. |
| 44 |
See \code{\link[=skim_with]{skim_with()}} for more details on customizing \code{skim()} and |
| 45 |
\code{\link[=get_default_skimmers]{get_default_skimmers()}} for a list of default functions. |
| 46 |
|
| 47 |
If you just want to see the printed output, call \code{skim_tee()} instead. |
| 48 |
This function returns the original data. \code{skim_tee()} uses the default |
| 49 |
\code{skim()}, but you can replace it with the \code{skim} argument. |
| 50 |
|
| 51 |
The data frame produced by \code{skim} is wide and sparse. To avoid type coercion |
| 52 |
\code{skimr} uses a type namespace for all summary statistics. Columns for numeric |
| 53 |
summary statistics all begin \code{numeric}; for factor summary statistics |
| 54 |
begin \code{factor}; and so on. |
| 55 |
|
| 56 |
See \code{\link[=partition]{partition()}} and \code{\link[=yank]{yank()}} for methods for transforming this wide data |
| 57 |
frame. The first function splits it into a list, with each entry |
| 58 |
corresponding to a data type. The latter pulls a single subtable for a |
| 59 |
particular type from the \code{skim_df}. |
| 60 |
|
| 61 |
\code{skim()} is designed to operate in pipes and to generally play nicely with |
| 62 |
other \code{tidyverse} functions. This means that you can use \code{tidyselect} helpers |
| 63 |
within \code{skim} to select or drop specific columns for summary. You can also |
| 64 |
further work with a \code{skim_df} using \code{dplyr} functions in a pipeline. |
| 65 |
} |
| 66 |
\section{Customizing skim}{ |
| 67 |
|
| 68 |
\code{skim()} is an intentionally simple function, with minimal arguments like |
| 69 |
\code{\link[=summary]{summary()}}. Nonetheless, this package provides two broad approaches to |
| 70 |
how you can customize \code{skim()}'s behavior. You can customize the functions |
| 71 |
that are called to produce summary statistics with \code{\link[=skim_with]{skim_with()}}. |
| 72 |
} |
| 73 |
|
| 74 |
\section{Unicode rendering}{ |
| 75 |
|
| 76 |
If the rendered examples show unencoded values such as \verb{<U+2587>} you will |
| 77 |
need to change your locale to allow proper rendering. Please review the |
| 78 |
\emph{Using Skimr} vignette for more information |
| 79 |
(\code{vignette("skimr", package = "skimr")}). |
| 80 |
|
| 81 |
Otherwise, we export \code{skim_without_charts()} to produce summaries without the |
| 82 |
spark graphs. These are the source of the unicode dependency. |
| 83 |
} |
| 84 |
|
| 85 |
\examples{ |
| 86 |
skim(iris) |
| 87 |
|
| 88 |
# Use tidyselect |
| 89 |
skim(iris, Species) |
| 90 |
skim(iris, starts_with("Sepal")) |
| 91 |
skim(iris, where(is.numeric)) |
| 92 |
|
| 93 |
# Skim also works groupwise |
| 94 |
iris |> |
| 95 |
dplyr::group_by(Species) |> |
| 96 |
skim() |
| 97 |
|
| 98 |
# Which five numeric columns have the greatest mean value? |
| 99 |
# Look in the `numeric.mean` column. |
| 100 |
iris |> |
| 101 |
skim() |> |
| 102 |
dplyr::select(numeric.mean) |> |
| 103 |
dplyr::slice_head(n = 5) |
| 104 |
|
| 105 |
# Which of my columns have missing values? Use the base skimmer n_missing. |
| 106 |
iris |> |
| 107 |
skim() |> |
| 108 |
dplyr::filter(n_missing > 0) |
| 109 |
|
| 110 |
# Use skim_tee to view the skim results and |
| 111 |
# continue using the original data. |
| 112 |
chickwts |> |
| 113 |
skim_tee() |> |
| 114 |
dplyr::filter(feed == "sunflower") |
| 115 |
|
| 116 |
# Produce a summary without spark graphs |
| 117 |
iris |> |
| 118 |
skim_without_charts() |
| 119 |
} |