These methods modify the data in a mrgsims object and return a data frame. Contrast with the functions in mrgsims_modify.

# S3 method for mrgsims
pull(.data, ...)

# S3 method for mrgsims
filter(.data, ...)

# S3 method for mrgsims
group_by(.data, ..., add = FALSE, .add = FALSE)

# S3 method for mrgsims
distinct(.data, ..., .keep_all = FALSE)

# S3 method for mrgsims
mutate(.data, ...)

# S3 method for each
summarise(.data, funs, ...)

# S3 method for mrgsims
summarise(.data, ...)

# S3 method for mrgsims
do(.data, ..., .dots)

# S3 method for mrgsims
select(.data, ...)

# S3 method for mrgsims
slice(.data, ...)

as_data_frame.mrgsims(.data_, ...)

# S3 method for mrgsims
as_tibble(.data_, ...)

as.tbl.mrgsims(x, ...)

Arguments

.data

an mrgsims object; passed to various dplyr functions

...

passed to other methods

add

passed to dplyr::group_by (for dplyr < 1.0.0)

.add

passed to dplyr::group_by (for dplyr >= 1.0.0)

.keep_all

passed to dplyr::distinct

funs

passed to dplyr::summarise_each

.dots

passed to various dplyr functions

.data_

mrgsims object

x

passed to dplyr::as.tbl

Details

For the select_sims function, the dots ... must be either compartment names or variables in $CAPTURE. An error will be generated if no valid names are selected or the names for selection are not found in the simulated output.

See also

Examples


out <- mrgsim(house(), events = ev(amt = 100), end = 5, delta=1)

dplyr::filter(out, time==2)
#> # A tibble: 1 × 7
#>      ID  time   GUT  CENT  RESP    DV    CP
#>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1     1     2  9.07  85.0  36.4  4.25  4.25

dplyr::mutate(out, label = "abc")
#> # A tibble: 7 × 8
#>      ID  time     GUT  CENT  RESP    DV    CP label
#>   <dbl> <dbl>   <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1     1     0   0       0    50    0     0    abc  
#> 2     1     0 100       0    50    0     0    abc  
#> 3     1     1  30.1    67.8  41.4  3.39  3.39 abc  
#> 4     1     2   9.07   85.0  36.4  4.25  4.25 abc  
#> 5     1     3   2.73   87.0  35.1  4.35  4.35 abc  
#> 6     1     4   0.823  84.6  35.0  4.23  4.23 abc  
#> 7     1     5   0.248  81.0  35.4  4.05  4.05 abc  

dplyr::select(out, time, RESP, CP)
#> # A tibble: 7 × 3
#>    time  RESP    CP
#>   <dbl> <dbl> <dbl>
#> 1     0  50    0   
#> 2     0  50    0   
#> 3     1  41.4  3.39
#> 4     2  36.4  4.25
#> 5     3  35.1  4.35
#> 6     4  35.0  4.23
#> 7     5  35.4  4.05