| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/get_skimmers.R |
| 3 |
\name{get_skimmers} |
| 4 |
\alias{get_skimmers} |
| 5 |
\alias{get_skimmers.default} |
| 6 |
\alias{get_skimmers.numeric} |
| 7 |
\alias{get_skimmers.factor} |
| 8 |
\alias{get_skimmers.character} |
| 9 |
\alias{get_skimmers.logical} |
| 10 |
\alias{get_skimmers.complex} |
| 11 |
\alias{get_skimmers.Date} |
| 12 |
\alias{get_skimmers.POSIXct} |
| 13 |
\alias{get_skimmers.difftime} |
| 14 |
\alias{get_skimmers.Timespan} |
| 15 |
\alias{get_skimmers.ts} |
| 16 |
\alias{get_skimmers.list} |
| 17 |
\alias{get_skimmers.AsIs} |
| 18 |
\alias{get_skimmers.haven_labelled} |
| 19 |
\alias{modify_default_skimmers} |
| 20 |
\title{Retrieve the summary functions for a specific data type} |
| 21 |
\usage{ |
| 22 |
get_skimmers(column) |
| 23 |
|
| 24 |
\method{get_skimmers}{default}(column) |
| 25 |
|
| 26 |
\method{get_skimmers}{numeric}(column) |
| 27 |
|
| 28 |
\method{get_skimmers}{factor}(column) |
| 29 |
|
| 30 |
\method{get_skimmers}{character}(column) |
| 31 |
|
| 32 |
\method{get_skimmers}{logical}(column) |
| 33 |
|
| 34 |
\method{get_skimmers}{complex}(column) |
| 35 |
|
| 36 |
\method{get_skimmers}{Date}(column) |
| 37 |
|
| 38 |
\method{get_skimmers}{POSIXct}(column) |
| 39 |
|
| 40 |
\method{get_skimmers}{difftime}(column) |
| 41 |
|
| 42 |
\method{get_skimmers}{Timespan}(column) |
| 43 |
|
| 44 |
\method{get_skimmers}{ts}(column) |
| 45 |
|
| 46 |
\method{get_skimmers}{list}(column) |
| 47 |
|
| 48 |
\method{get_skimmers}{AsIs}(column) |
| 49 |
|
| 50 |
\method{get_skimmers}{haven_labelled}(column) |
| 51 |
|
| 52 |
modify_default_skimmers(skim_type, new_skim_type = NULL, new_funs = list()) |
| 53 |
} |
| 54 |
\arguments{ |
| 55 |
\item{column}{An atomic vector or list. A column from a data frame.} |
| 56 |
|
| 57 |
\item{skim_type}{A character scalar. The class of the object with default |
| 58 |
skimmers.} |
| 59 |
|
| 60 |
\item{new_skim_type}{The type to assign to the looked up set of skimmers.} |
| 61 |
|
| 62 |
\item{new_funs}{Replacement functions for those in} |
| 63 |
} |
| 64 |
\value{ |
| 65 |
A \code{skim_function_list} object. |
| 66 |
} |
| 67 |
\description{ |
| 68 |
These functions are used to set the default skimming functions for a data |
| 69 |
type. They are combined with the base skim function list (\code{sfl}) in |
| 70 |
\code{\link[=skim_with]{skim_with()}}, to create the summary tibble for each type. |
| 71 |
} |
| 72 |
\details{ |
| 73 |
When creating your own set of skimming functions, call \code{\link[=sfl]{sfl()}} within a |
| 74 |
\code{\link[=get_skimmers]{get_skimmers()}} method for your particular type. Your call to \code{\link[=sfl]{sfl()}} should |
| 75 |
also provide a matching class in the \code{skim_type} argument. Otherwise, it |
| 76 |
will not be possible to dynamically reassign your default functions when |
| 77 |
working interactively. |
| 78 |
|
| 79 |
Call \code{\link[=get_default_skimmers]{get_default_skimmers()}} to see the functions for each type of summary |
| 80 |
function currently supported. Call \code{\link[=get_default_skimmer_names]{get_default_skimmer_names()}} to just see |
| 81 |
the names of these functions. Use \code{\link[=modify_default_skimmers]{modify_default_skimmers()}} for a method |
| 82 |
for changing the \code{skim_type} or functions for a default \code{sfl}. This is useful |
| 83 |
for creating new default \code{sfl}'s. |
| 84 |
} |
| 85 |
\section{Methods (by class)}{ |
| 86 |
\itemize{ |
| 87 |
\item \code{get_skimmers(default)}: The default method for skimming data. Only used when |
| 88 |
a column's data type doesn't match currently installed types. Call |
| 89 |
\link{get_default_skimmer_names} to see these defaults. |
| 90 |
|
| 91 |
\item \code{get_skimmers(numeric)}: Summary functions for numeric columns, covering both |
| 92 |
\code{\link[=double]{double()}} and \code{\link[=integer]{integer()}} classes: \code{\link[=mean]{mean()}}, \code{\link[=sd]{sd()}}, \code{\link[=quantile]{quantile()}} and |
| 93 |
\code{\link[=inline_hist]{inline_hist()}}. |
| 94 |
|
| 95 |
\item \code{get_skimmers(factor)}: Summary functions for factor columns: |
| 96 |
\code{\link[=is.ordered]{is.ordered()}}, \code{\link[=n_unique]{n_unique()}} and \code{\link[=top_counts]{top_counts()}}. |
| 97 |
|
| 98 |
\item \code{get_skimmers(character)}: Summary functions for character columns. Also, the |
| 99 |
default for unknown columns: \code{\link[=min_char]{min_char()}}, \code{\link[=max_char]{max_char()}}, \code{\link[=n_empty]{n_empty()}}, |
| 100 |
\code{\link[=n_unique]{n_unique()}} and \code{\link[=n_whitespace]{n_whitespace()}}. |
| 101 |
|
| 102 |
\item \code{get_skimmers(logical)}: Summary functions for logical/ boolean columns: |
| 103 |
\code{\link[=mean]{mean()}}, which produces rates for each value, and \code{\link[=top_counts]{top_counts()}}. |
| 104 |
|
| 105 |
\item \code{get_skimmers(complex)}: Summary functions for complex columns: \code{\link[=mean]{mean()}}. |
| 106 |
|
| 107 |
\item \code{get_skimmers(Date)}: Summary functions for \code{Date} columns: \code{\link[=min]{min()}}, |
| 108 |
\code{\link[=max]{max()}}, \code{\link[=median]{median()}} and \code{\link[=n_unique]{n_unique()}}. |
| 109 |
|
| 110 |
\item \code{get_skimmers(POSIXct)}: Summary functions for \code{POSIXct} columns: \code{\link[=min]{min()}}, |
| 111 |
\code{\link[=max]{max()}}, \code{\link[=median]{median()}} and \code{\link[=n_unique]{n_unique()}}. |
| 112 |
|
| 113 |
\item \code{get_skimmers(difftime)}: Summary functions for \code{difftime} columns: \code{\link[=min]{min()}}, |
| 114 |
\code{\link[=max]{max()}}, \code{\link[=median]{median()}} and \code{\link[=n_unique]{n_unique()}}. |
| 115 |
|
| 116 |
\item \code{get_skimmers(Timespan)}: Summary functions for \code{Timespan} columns: \code{\link[=min]{min()}}, |
| 117 |
\code{\link[=max]{max()}}, \code{\link[=median]{median()}} and \code{\link[=n_unique]{n_unique()}}. |
| 118 |
|
| 119 |
\item \code{get_skimmers(ts)}: Summary functions for \code{ts} columns: \code{\link[=min]{min()}}, |
| 120 |
\code{\link[=max]{max()}}, \code{\link[=median]{median()}} and \code{\link[=n_unique]{n_unique()}}. |
| 121 |
|
| 122 |
\item \code{get_skimmers(list)}: Summary functions for \code{list} columns: \code{\link[=n_unique]{n_unique()}}, |
| 123 |
\code{\link[=list_min_length]{list_min_length()}} and \code{\link[=list_max_length]{list_max_length()}}. |
| 124 |
|
| 125 |
\item \code{get_skimmers(AsIs)}: Summary functions for \code{AsIs} columns: \code{\link[=n_unique]{n_unique()}}, |
| 126 |
\code{\link[=list_min_length]{list_min_length()}} and \code{\link[=list_max_length]{list_max_length()}}. |
| 127 |
|
| 128 |
\item \code{get_skimmers(haven_labelled)}: Summary functions for \code{haven_labelled} columns. |
| 129 |
Finds the appropriate skimmers for the underlying data in the vector. |
| 130 |
|
| 131 |
}} |
| 132 |
\examples{ |
| 133 |
# Defining default skimming functions for a new class, `my_class`. |
| 134 |
# Note that the class argument is required for dynamic reassignment. |
| 135 |
get_skimmers.my_class <- function(column) { |
| 136 |
sfl( |
| 137 |
skim_type = "my_class", |
| 138 |
mean, |
| 139 |
sd |
| 140 |
) |
| 141 |
} |
| 142 |
|
| 143 |
# Integer and double columns are both "numeric" and are treated the same |
| 144 |
# by default. To switch this behavior in another package, add a method. |
| 145 |
get_skimmers.integer <- function(column) { |
| 146 |
sfl( |
| 147 |
skim_type = "integer", |
| 148 |
p50 = ~ stats::quantile( |
| 149 |
., |
| 150 |
probs = .50, na.rm = TRUE, names = FALSE, type = 1 |
| 151 |
) |
| 152 |
) |
| 153 |
} |
| 154 |
x <- mtcars[c("gear", "carb")] |
| 155 |
class(x$carb) <- "integer" |
| 156 |
skim(x) |
| 157 |
\dontrun{ |
| 158 |
# In a package, to revert to the V1 behavior of skimming separately with the |
| 159 |
# same functions, assign the numeric `get_skimmers`. |
| 160 |
get_skimmers.integer <- skimr::get_skimmers.numeric |
| 161 |
|
| 162 |
# Or, in a local session, use `skim_with` to create a different `skim`. |
| 163 |
new_skim <- skim_with(integer = skimr::get_skimmers.numeric()) |
| 164 |
|
| 165 |
# To apply a set of skimmers from an old type to a new type |
| 166 |
get_skimmers.new_type <- function(column) { |
| 167 |
modify_default_skimmers("old_type", new_skim_type = "new_type") |
| 168 |
} |
| 169 |
} |
| 170 |
} |
| 171 |
\seealso{ |
| 172 |
\code{\link[=sfl]{sfl()}} |
| 173 |
} |