Debian Codegraph @

man/tidy.kde.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/ks.R
3 \name{tidy.kde}
4 \alias{tidy.kde}
5 \alias{kde_tidiers}
6 \alias{ks_tidiers}
7 \title{Tidy a(n) kde object}
8 \usage{
9 \method{tidy}{kde}(x, ...)
10 }
11 \arguments{
12 \item{x}{A \code{kde} object returned from \code{\link[ks:kde]{ks::kde()}}.}
13
14 \item{...}{Additional arguments. Not used. Needed to match generic
15 signature only. \strong{Cautionary note:} Misspelled arguments will be
16 absorbed in \code{...}, where they will be ignored. If the misspelled
17 argument has a default value, the default value will be used.
18 For example, if you pass \code{conf.lvel = 0.9}, all computation will
19 proceed using \code{conf.level = 0.95}. Two exceptions here are:
20 \itemize{
21 \item \code{tidy()} methods will warn when supplied an \code{exponentiate} argument if
22 it will be ignored.
23 \item \code{augment()} methods will warn when supplied a \code{newdata} argument if it
24 will be ignored.
25 }}
26 }
27 \description{
28 Tidy summarizes information about the components of a model.
29 A model component might be a single term in a regression, a single
30 hypothesis, a cluster, or a class. Exactly what tidy considers to be a
31 model component varies across models but is usually self-evident.
32 If a model has several distinct types of components, you will need to
33 specify which components to return.
34 }
35 \details{
36 Returns a data frame in long format with four columns. Use
37 \code{tidyr::pivot_wider(..., names_from = variable, values_from = value)}
38 on the output to return to a wide format.
39 }
40 \examples{
41 \dontshow{if (rlang::is_installed(c("ks", "ggplot2"))) withAutoprint(\{ # examplesIf}
42
43 # load libraries for models and data
44 library(ks)
45
46 # generate data
47 dat <- replicate(2, rnorm(100))
48 k <- kde(dat)
49
50 # summarize model fit with tidiers + visualization
51 td <- tidy(k)
52 td
53
54 library(ggplot2)
55 library(dplyr)
56 library(tidyr)
57
58 td |>
59 pivot_wider(c(obs, estimate),
60 names_from = variable,
61 values_from = value
62 ) |>
63 ggplot(aes(x1, x2, fill = estimate)) +
64 geom_tile() +
65 theme_void()
66
67 # also works with 3 dimensions
68 dat3 <- replicate(3, rnorm(100))
69 k3 <- kde(dat3)
70
71 td3 <- tidy(k3)
72 td3
73 \dontshow{\}) # examplesIf}
74 }
75 \seealso{
76 \code{\link[=tidy]{tidy()}}, \code{\link[ks:kde]{ks::kde()}}
77 }
78 \value{
79 A \code{\link[tibble:tibble]{tibble::tibble()}} with columns:
80 \item{estimate}{The estimated value of the regression term.}
81 \item{obs}{weighted observed number of events in each group.}
82 \item{value}{The value/estimate of the component. Results from data reshaping.}
83 \item{variable}{Variable under consideration.}
84
85 }