-
Notifications
You must be signed in to change notification settings - Fork 3
/
opt_bin.Rd
49 lines (43 loc) · 1.13 KB
/
opt_bin.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/optimal_bin_size.R
\name{opt_bin}
\alias{opt_bin}
\title{Get the optimal binwidth for a histogram}
\usage{
opt_bin(.data, .value_col, .iters = 30)
}
\arguments{
\item{.data}{The data set in question}
\item{.value_col}{The column that holds the values}
\item{.iters}{How many times the cost function loop should run}
}
\value{
A tibble of histogram breakpoints
}
\description{
Gives the optimal binwidth for a histogram given a data set, it's value and
the desired amount of bins
}
\details{
Modified from Hideaki Shimazaki
Department of Physics, Kyoto University
shimazaki at ton.scphys.kyoto-u.ac.jp
Feel free to modify/distribute this program.
\itemize{
\item Supply a data.frame/tibble with a value column. from this an optimal binwidth
will be computed for the amount of binds desired
}
}
\examples{
suppressPackageStartupMessages(library(purrr))
suppressPackageStartupMessages(library(dplyr))
df_tbl <- rnorm(n = 1000, mean = 0, sd = 1)
df_tbl <- df_tbl \%>\%
as_tibble() \%>\%
set_names("value")
df_tbl \%>\%
opt_bin(
.value_col = value
, .iters = 100
)
}