Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ S3method(as.matrix,ev)
S3method(as_tibble,mrgsims)
S3method(compiled,default)
S3method(compiled,mrgmod)
S3method(count,mrgsims)
S3method(cvec,character)
S3method(dim,ev)
S3method(distinct,mrgsims)
Expand Down Expand Up @@ -245,6 +246,7 @@ import(methods)
importFrom(Rcpp,evalCpp)
importFrom(dplyr,arrange)
importFrom(dplyr,bind_rows)
importFrom(dplyr,count)
importFrom(dplyr,distinct)
importFrom(dplyr,do)
importFrom(dplyr,filter)
Expand Down
2 changes: 1 addition & 1 deletion R/Aaaa.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#' @importFrom dplyr bind_rows arrange summarise summarise_at mutate_if
#' @importFrom dplyr intersect select rename do slice pull
#' @importFrom dplyr if_else summarise_each is.tbl select
#' @importFrom dplyr group_by ungroup n left_join
#' @importFrom dplyr group_by ungroup n left_join count
#' @importFrom tidyselect vars_select everything
#' @importFrom magrittr %>%
#' @importFrom tibble tibble as_tibble
Expand Down
49 changes: 27 additions & 22 deletions R/mrgsims.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ pull.mrgsims <- function(.data, ...) {
dplyr::pull(as_tibble.mrgsims(.data), ...)
}

##' @method filter mrgsims
##' @rdname mrgsims_dplyr
##' @export
#' @method filter mrgsims
#' @rdname mrgsims_dplyr
#' @export
filter.mrgsims <- function(.data,...) {
dplyr::filter(as_tibble.mrgsims(.data),...)
}

##' @rdname mrgsims_dplyr
##' @export
#' @rdname mrgsims_dplyr
#' @export
group_by.mrgsims <- function(.data,...,add=FALSE,.add=FALSE) {
if(DPLYR_1_0_0) {
return(dplyr::group_by(as_tibble.mrgsims(.data), ..., .add = .add))
Expand All @@ -190,55 +190,60 @@ group_by.mrgsims <- function(.data,...,add=FALSE,.add=FALSE) {
}
}

##' @rdname mrgsims_dplyr
##' @export
#' @rdname mrgsims_dplyr
#' @export
distinct.mrgsims <- function(.data,...,.keep_all=FALSE) {
dplyr::distinct(as_tibble.mrgsims(.data),...,.keep_all=.keep_all)
}

##' @rdname mrgsims_dplyr
##' @export
#' @rdname mrgsims_dplyr
#' @export
mutate.mrgsims <- function(.data,...) {
dplyr::mutate(as_tibble.mrgsims(.data),...)
}

##' @rdname mrgsims_dplyr
##' @export
#' @rdname mrgsims_dplyr
#' @export
summarise.each <- function(.data,funs,...) {
dplyr::summarise_each(as_tibble.mrgsims(.data),funs,...)
}

##' @rdname mrgsims_dplyr
##' @export
#' @rdname mrgsims_dplyr
#' @export
summarise.mrgsims <- function(.data,...) {
dplyr::summarise(as_tibble.mrgsims(.data),...)
}

##' @rdname mrgsims_dplyr
##' @export
#' @rdname mrgsims_dplyr
#' @export
do.mrgsims <- function(.data,...,.dots) {
dplyr::do(as_tibble.mrgsims(.data),...)
}

##' @rdname mrgsims_dplyr
##' @export
#' @rdname mrgsims_dplyr
#' @export
select.mrgsims <- function(.data,...) {
dplyr::select(as_tibble.mrgsims(.data),...)
}

##' @rdname mrgsims_dplyr
##' @export
#' @rdname mrgsims_dplyr
#' @export
slice.mrgsims <- function(.data,...) {
dplyr::slice(as_tibble.mrgsims(.data),...)
}

##' @rdname mrgsims_dplyr
##' @export
#' @rdname mrgsims_dplyr
#' @export
count.mrgsims <- function(x, ...) {
dplyr::count(as_tibble.mrgsims(x), ...)
}

#' @rdname mrgsims_dplyr
#' @export
as_data_frame.mrgsims <- function(x,...) {
as_tibble(as.data.frame(x),...)
}


#' @param x mrgsims object.
#'
#' @rdname mrgsims_dplyr
Expand Down
3 changes: 3 additions & 0 deletions man/mrgsims_dplyr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion tests/testthat/test-dplyr-generics.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2013 - 2020 Metrum Research Group
# Copyright (C) 2013 - 2024 Metrum Research Group
#
# This file is part of mrgsolve.
#
Expand Down Expand Up @@ -69,6 +69,11 @@ test_that("Pipe to slice", {
expect_true(all(x$time %in% c(1,2.25)))
})

test_that("Pipe to count", {
x <- count(out, ID)
expect_is(x, "data.frame")
})

test_that("filter_mrgsims", {
x <- out %>% filter_sims(time > 30)
expect_is(x, "mrgsims")
Expand Down
Loading