Skip to contents

# Tidy Empirical

Source: `R/empirical-tidy.R`
`tidy_empirical.Rd`

This function takes in a single argument of .x a vector and will return a tibble of information similar to the `tidy_` distribution functions. The `y` column is set equal to `dy` from the density function.

## Usage

    tidy_empirical(.x, .num_sims = 1, .distribution_type = "continuous")

## Arguments

.x

  A vector of numbers

.num_sims

  How many simulations should be run, defaults to 1.

.distribution_type

  A string of either "continuous" or "discrete". The function will default to "continuous"

## Value

A tibble

## Details

This function takes in a single argument of .x a vector

## Author

Steven P. Sanderson II, MPH

## Examples

    x <- mtcars$mpg
    tidy_empirical(.x = x, .distribution_type = "continuous")
    #> # A tibble: 32 × 7
    #>    sim_number     x     y    dx       dy     p     q
    #>    <fct>      <int> <dbl> <dbl>    <dbl> <dbl> <dbl>
    #>  1 1              1  21    2.97 0.000114 0.625  10.4
    #>  2 1              2  21    4.21 0.000455 0.625  10.4
    #>  3 1              3  22.8  5.44 0.00142  0.781  13.3
    #>  4 1              4  21.4  6.68 0.00355  0.688  14.3
    #>  5 1              5  18.7  7.92 0.00721  0.469  14.7
    #>  6 1              6  18.1  9.16 0.0124   0.438  15
    #>  7 1              7  14.3 10.4  0.0192   0.125  15.2
    #>  8 1              8  24.4 11.6  0.0281   0.812  15.2
    #>  9 1              9  22.8 12.9  0.0395   0.781  15.5
    #> 10 1             10  19.2 14.1  0.0516   0.531  15.8
    #> # ℹ 22 more rows
    tidy_empirical(.x = x, .num_sims = 10, .distribution_type = "continuous")
    #> # A tibble: 320 × 7
    #>    sim_number     x     y    dx        dy      p     q
    #>    <fct>      <int> <dbl> <dbl>     <dbl>  <dbl> <dbl>
    #>  1 1              1  19.2  4.41 0.0000702 0.531   10.4
    #>  2 1              2  15.5  5.55 0.000331  0.281   14.7
    #>  3 1              3  21    6.70 0.00113   0.625   14.7
    #>  4 1              4  21.4  7.84 0.00279   0.688   15.5
    #>  5 1              5  27.3  8.98 0.00512   0.875   15.8
    #>  6 1              6  21   10.1  0.00740   0.625   17.3
    #>  7 1              7  32.4 11.3  0.00984   0.969   17.8
    #>  8 1              8  21.4 12.4  0.0144    0.688   17.8
    #>  9 1              9  14.7 13.6  0.0224    0.156   19.2
    #> 10 1             10  10.4 14.7  0.0324    0.0625  19.2
    #> # ℹ 310 more rows