bin_data: Bin the raw data

Description Usage Arguments Value See Also Examples

View source: R/bin_data.R

Description

Create data frame of binned counts

Usage

1
bin_data(z_vector, binv = "median", zstar, binwidth, bins_l, bins_r)

Arguments

z_vector

a numeric vector of (unbinned) data.

binv

a string setting location of zstar within its bin ("min", "max" or "median" value). Default is median.

zstar

a numeric value for the the bunching point.

binwidth

a numeric value for the width of each bin.

bins_l

number of bins to left of zstar to use in analysis.

bins_r

number of bins to right of zstar to use in analysis.

Value

bin_data returns a data frame with bins and corresponding frequencies (counts).

See Also

bunchit

Examples

1
2
3
4
data(bunching_data)
binned_data <- bin_data(z_vector = bunching_data$kink, zstar = 10000,
                        binwidth = 50, bins_l = 20, bins_r = 20)
head(binned_data)

Example output

Loading required package: BB
Loading required package: dplyr

Attaching package:dplyrThe following objects are masked frompackage:stats:

    filter, lag

The following objects are masked frompackage:base:

    intersect, setdiff, setequal, union

Loading required package: ggplot2
Loading required package: tidyr
   bin freq    z freq_orig
1 9050  385 9045       385
2 9100  370 9095       370
3 9150  385 9145       385
4 9200  355 9195       355
5 9250  335 9245       335
6 9300  375 9295       375

bunching documentation built on Sept. 23, 2019, 5:04 p.m.