From 36940fd7326acdeec252d3d0494305366b99c3d6 Mon Sep 17 00:00:00 2001
From: Kyle Baron
Date: Tue, 28 Jan 2020 12:38:32 -0600
Subject: [PATCH 04/17] clarify some of the documentation
---
DESCRIPTION | 6 ++++--
R/lastdose.R | 17 ++++++++++++++---
man/lastdose.Rd | 16 +++++++++++++---
3 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/DESCRIPTION b/DESCRIPTION
index dc85bfe..5919b93 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -2,8 +2,10 @@ Package: lastdose
Type: Package
Title: Calculate Time and Amount of Last Dose
Version: 0.2.0
-Author: Kyle Baron
-Maintainer: Kyle Baron
+Authors@R: c(
+ person("Kyle T", "Baron", email = "kyleb@metrumrg.com", role=c("aut", "cre"), comment=c(ORCID="0000-0001-7252-5656"))
+ )
+Maintainer: Kyle T Baron
Description: Efficient calculation of time after last dose and last dose amount
for analysis data sets.
License: GPL (>=2)
diff --git a/R/lastdose.R b/R/lastdose.R
index 4f70fe8..05af751 100644
--- a/R/lastdose.R
+++ b/R/lastdose.R
@@ -4,9 +4,9 @@ NULL
#' Calculate last dose amount (LDOS) and time after last dose (TAD)
#'
-#' Use [lastdose] to columns to the input data frame; [lastdose_list]
-#' and [lastdose_df] returns calculated information as either
-#' `list` or `data.frame` format without modifying the input data.
+#' Use [lastdose] to add (or potentially replace) columns to the input
+#' data frame; [lastdose_list] and [lastdose_df] returns calculated information
+#' as either `list` or `data.frame` format without modifying the input data.
#'
#' @param data data set as data frame; see `details`
#' @param back_calc if `TRUE`, then the time before the first dose
@@ -27,6 +27,17 @@ NULL
#'
#' @details
#'
+#' When calling [lastdose] to modify the data frame, two columns will be
+#' added (by default): `TAD` indicating the time after the most-recent dose
+#' and `LDOS` indicating the amount of the most recent dose. This default
+#' behavior can be modified with the `include_ldos` argument.
+#'
+#' When calling [lastdose_list] or [lastdose_df], the respective items are
+#' accessible with `tad` and `ldos` (note the lower case form here to
+#' distinguish from the columns that might be added to the data frame).
+#'
+#' Additional notes regarding behavior:
+#'
#' - All functions require an input data set as a data frame
#' - The data set should be formatted according to `NMTRAN` type
#' conventions
diff --git a/man/lastdose.Rd b/man/lastdose.Rd
index 1effd2c..e1b9983 100644
--- a/man/lastdose.Rd
+++ b/man/lastdose.Rd
@@ -41,11 +41,21 @@ and the observation made immediately after (with no advance in time). See
details.}
}
\description{
-Use \link{lastdose} to columns to the input data frame; \link{lastdose_list}
-and \link{lastdose_df} returns calculated information as either
-\code{list} or \code{data.frame} format without modifying the input data.
+Use \link{lastdose} to add (or potentially replace) columns to the input
+data frame; \link{lastdose_list} and \link{lastdose_df} returns calculated information
+as either \code{list} or \code{data.frame} format without modifying the input data.
}
\details{
+When calling \link{lastdose} to modify the data frame, two columns will be
+added (by default): \code{TAD} indicating the time after the most-recent dose
+and \code{LDOS} indicating the amount of the most recent dose. This default
+behavior can be modified with the \code{include_ldos} argument.
+
+When calling \link{lastdose_list} or \link{lastdose_df}, the respective items are
+accessible with \code{tad} and \code{ldos} (note the lower case form here to
+distinguish from the columns that might be added to the data frame).
+
+Additional notes regarding behavior:
\itemize{
\item All functions require an input data set as a data frame
\item The data set should be formatted according to \code{NMTRAN} type
From d8973e7893936d0abb2c40456043d289b6640556 Mon Sep 17 00:00:00 2001
From: Kyle Baron
Date: Tue, 28 Jan 2020 12:39:08 -0600
Subject: [PATCH 05/17] re-build pkgdown site
---
README.md | 4 ++--
docs/404.html | 2 +-
docs/authors.html | 4 ++--
docs/index.html | 8 ++++----
docs/news/index.html | 2 +-
docs/reference/index.html | 2 +-
docs/reference/lastdose.html | 24 +++++++++++++++---------
7 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
index a005e54..1494a45 100644
--- a/README.md
+++ b/README.md
@@ -163,7 +163,7 @@ system.time(x2 <- lastdose(big))
```
. user system elapsed
- . 0.047 0.002 0.049
+ . 0.045 0.001 0.047
## Compare against the single profile
@@ -172,7 +172,7 @@ system.time(x1 <- lastdose(df))
```
. user system elapsed
- . 0 0 0
+ . 0.001 0.000 0.000
``` r
x3 <- filter(x2, big[["ID"]]==1) %>% as.data.frame()
diff --git a/docs/404.html b/docs/404.html
index 62e79e0..68b5ee1 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -119,7 +119,7 @@
This function uses specific criteria for finding comment records that may
+not match up with your coding conventions. See details below as well as
+unit tests.
find_comments(x, ...)
@@ -141,6 +145,14 @@
Arg
Value
A logical vector
+
Details
+
+
For the data frame method, comments are found in a column with name C
+with type character. If a C column is found that is not character,
+a warning is generated and no comments are found.
+
For the character method or when an appropriate C column is found when
+using the data frame method, a position or row is considered a comment
+when it is either NA or when it is equal to ..
diff --git a/man/find_comments.Rd b/man/find_comments.Rd
index 87db55e..68346fd 100644
--- a/man/find_comments.Rd
+++ b/man/find_comments.Rd
@@ -21,7 +21,18 @@ find_comments(x, ...)
A logical vector
}
\description{
-Find commented records
+This function uses specific criteria for finding comment records that may
+not match up with your coding conventions. See details below as well as
+unit tests.
+}
+\details{
+For the data frame method, comments are found in a column with name \code{C}
+with type \code{character}. If a \code{C} column is found that is not character,
+a warning is generated and no comments are found.
+
+For the character method or when an appropriate \code{C} column is found when
+using the data frame method, a position or row is considered a comment
+when it is either \code{NA} or when it is equal to \code{.}.
}
\examples{
comment <- c(NA, "C", "C", NA, ".", NA, "Comment")
@@ -30,4 +41,5 @@ df <- data.frame(C = comment , DV = dv)
find_comments(df)
+
}
From 2342cdb3b86e9e5cd1394749fe57290af5eafa39 Mon Sep 17 00:00:00 2001
From: Kyle Baron
Date: Thu, 30 Jan 2020 23:12:39 -0600
Subject: [PATCH 10/17] accept comment of length 1
---
R/lastdose.R | 3 +++
1 file changed, 3 insertions(+)
diff --git a/R/lastdose.R b/R/lastdose.R
index bbed4ad..0c2acba 100644
--- a/R/lastdose.R
+++ b/R/lastdose.R
@@ -94,6 +94,9 @@ lastdose <- function(data,..., include_ldos = TRUE) {
lastdose_list <- function(data, fill = -99, back_calc = TRUE,
addl_ties = c("obs_first", "dose_first"),
comments = find_comments(data)) {
+ if(length(comments)==1) {
+ comments <- rep(comments,nrow(data))
+ }
if(!length(comments)==nrow(data)) {
stop("'comments' must be have length equal to the number of rows in 'data'",call.=FALSE)
}
From c134bd961ce43393cdfccea05219b2322312e925 Mon Sep 17 00:00:00 2001
From: Kyle Baron
Date: Thu, 30 Jan 2020 23:46:08 -0600
Subject: [PATCH 11/17] only fill commented records with NA when requested #8
---
R/RcppExports.R | 4 ++--
R/lastdose.R | 21 +++++++++++++++++----
man/lastdose.Rd | 19 ++++++++++++++++---
src/RcppExports.cpp | 9 +++++----
src/lastdose.cpp | 5 +++--
tests/testthat/test-lastdose.R | 3 +++
6 files changed, 46 insertions(+), 15 deletions(-)
diff --git a/R/RcppExports.R b/R/RcppExports.R
index 992d871..f2ab877 100644
--- a/R/RcppExports.R
+++ b/R/RcppExports.R
@@ -1,7 +1,7 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
-lastdose_impl <- function(id, time, amt, evid, addl, ii, fill, back_calc, sort1, comment) {
- .Call(`_lastdose_lastdose_impl`, id, time, amt, evid, addl, ii, fill, back_calc, sort1, comment)
+lastdose_impl <- function(id, time, amt, evid, addl, ii, fill, back_calc, sort1, comment, fill_comment_na) {
+ .Call(`_lastdose_lastdose_impl`, id, time, amt, evid, addl, ii, fill, back_calc, sort1, comment, fill_comment_na)
}
diff --git a/R/lastdose.R b/R/lastdose.R
index 0c2acba..72a9532 100644
--- a/R/lastdose.R
+++ b/R/lastdose.R
@@ -23,10 +23,14 @@ NULL
#' details.
#' @param comments a logcial vector with length equal to the number of rows
#' in `data` indicating which records are to be ignored when looking for `TAD`
-#' and `LDOS`.
+#' and `LDOS`. See all the `fill_comments_na` argument.
#' @param ... arguments passed to [lastdose_list]
#' @param include_ldos `logical`; if `FALSE` then the `LDOS` data is not
#' appended to the data set. Only used for the [lastdose] function.
+#' @param fill_comments_na if `TRUE`, then `TAD` and `LDOS` will be filled with
+#' `NA` when the comment indicator is `TRUE`; otherwise, commented records
+#' are filled in with the time since and amount of the dose on the last
+#' non-commented dosing record (the default).
#'
#' @details
#'
@@ -39,7 +43,14 @@ NULL
#' accessible with `tad` and `ldos` (note the lower case form here to
#' distinguish from the columns that might be added to the data frame).
#'
-#' Additional notes regarding behavior:
+#' **Handling of commented records**: Dosing records that have been "commented"
+#' (as indicated with the `comments` argument) will never be considered as
+#' actual doses when determining `TAD` and `LDOS`. But commented records (doses
+#' and non-doses) will be assigned `TAD` and `LDOS` according to the last
+#' non-commented dosing record by default. The behavior can be modified by
+#' setting through the `fill_comments_na` argument.
+#'
+#' **Additional notes**:
#'
#' - All functions require an input data set as a data frame
#' - The data set should be formatted according to `NMTRAN` type
@@ -93,7 +104,8 @@ lastdose <- function(data,..., include_ldos = TRUE) {
#' @export
lastdose_list <- function(data, fill = -99, back_calc = TRUE,
addl_ties = c("obs_first", "dose_first"),
- comments = find_comments(data)) {
+ comments = find_comments(data),
+ fill_comments_na = FALSE) {
if(length(comments)==1) {
comments <- rep(comments,nrow(data))
}
@@ -168,7 +180,8 @@ lastdose_list <- function(data, fill = -99, back_calc = TRUE,
fill,
back_calc,
sort1,
- comments
+ comments,
+ fill_comments_na
)
ans
}
diff --git a/man/lastdose.Rd b/man/lastdose.Rd
index 2b6aba6..f4ac70a 100644
--- a/man/lastdose.Rd
+++ b/man/lastdose.Rd
@@ -13,7 +13,8 @@ lastdose_list(
fill = -99,
back_calc = TRUE,
addl_ties = c("obs_first", "dose_first"),
- comments = find_comments(data)
+ comments = find_comments(data),
+ fill_comments_na = FALSE
)
lastdose_df(data, ...)
@@ -43,7 +44,12 @@ details.}
\item{comments}{a logcial vector with length equal to the number of rows
in \code{data} indicating which records are to be ignored when looking for \code{TAD}
-and \code{LDOS}.}
+and \code{LDOS}. See all the \code{fill_comments_na} argument.}
+
+\item{fill_comments_na}{if \code{TRUE}, then \code{TAD} and \code{LDOS} will be filled with
+\code{NA} when the comment indicator is \code{TRUE}; otherwise, commented records
+are filled in with the time since and amount of the dose on the last
+non-commented dosing record (the default).}
}
\description{
Use \link{lastdose} to add (or potentially replace) columns to the input
@@ -60,7 +66,14 @@ When calling \link{lastdose_list} or \link{lastdose_df}, the respective items ar
accessible with \code{tad} and \code{ldos} (note the lower case form here to
distinguish from the columns that might be added to the data frame).
-Additional notes regarding behavior:
+\strong{Handling of commented records}: Dosing records that have been "commented"
+(as indicated with the \code{comments} argument) will never be considered as
+actual doses when determining \code{TAD} and \code{LDOS}. But commented records (doses
+and non-doses) will be assigned \code{TAD} and \code{LDOS} according to the last
+non-commented dosing record by default. The behavior can be modified by
+setting through the \code{fill_comments_na} argument.
+
+\strong{Additional notes}:
\itemize{
\item All functions require an input data set as a data frame
\item The data set should be formatted according to \code{NMTRAN} type
diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp
index b315baa..d4b2aa7 100644
--- a/src/RcppExports.cpp
+++ b/src/RcppExports.cpp
@@ -6,8 +6,8 @@
using namespace Rcpp;
// lastdose_impl
-Rcpp::List lastdose_impl(Rcpp::NumericVector id, Rcpp::NumericVector time, Rcpp::NumericVector amt, Rcpp::NumericVector evid, Rcpp::NumericVector addl, Rcpp::NumericVector ii, Rcpp::NumericVector fill, Rcpp::LogicalVector back_calc, Rcpp::LogicalVector sort1, Rcpp::LogicalVector comment);
-RcppExport SEXP _lastdose_lastdose_impl(SEXP idSEXP, SEXP timeSEXP, SEXP amtSEXP, SEXP evidSEXP, SEXP addlSEXP, SEXP iiSEXP, SEXP fillSEXP, SEXP back_calcSEXP, SEXP sort1SEXP, SEXP commentSEXP) {
+Rcpp::List lastdose_impl(Rcpp::NumericVector id, Rcpp::NumericVector time, Rcpp::NumericVector amt, Rcpp::NumericVector evid, Rcpp::NumericVector addl, Rcpp::NumericVector ii, Rcpp::NumericVector fill, Rcpp::LogicalVector back_calc, Rcpp::LogicalVector sort1, Rcpp::LogicalVector comment, bool fill_comment_na);
+RcppExport SEXP _lastdose_lastdose_impl(SEXP idSEXP, SEXP timeSEXP, SEXP amtSEXP, SEXP evidSEXP, SEXP addlSEXP, SEXP iiSEXP, SEXP fillSEXP, SEXP back_calcSEXP, SEXP sort1SEXP, SEXP commentSEXP, SEXP fill_comment_naSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
@@ -21,13 +21,14 @@ BEGIN_RCPP
Rcpp::traits::input_parameter< Rcpp::LogicalVector >::type back_calc(back_calcSEXP);
Rcpp::traits::input_parameter< Rcpp::LogicalVector >::type sort1(sort1SEXP);
Rcpp::traits::input_parameter< Rcpp::LogicalVector >::type comment(commentSEXP);
- rcpp_result_gen = Rcpp::wrap(lastdose_impl(id, time, amt, evid, addl, ii, fill, back_calc, sort1, comment));
+ Rcpp::traits::input_parameter< bool >::type fill_comment_na(fill_comment_naSEXP);
+ rcpp_result_gen = Rcpp::wrap(lastdose_impl(id, time, amt, evid, addl, ii, fill, back_calc, sort1, comment, fill_comment_na));
return rcpp_result_gen;
END_RCPP
}
static const R_CallMethodDef CallEntries[] = {
- {"_lastdose_lastdose_impl", (DL_FUNC) &_lastdose_lastdose_impl, 10},
+ {"_lastdose_lastdose_impl", (DL_FUNC) &_lastdose_lastdose_impl, 11},
{NULL, NULL, 0}
};
diff --git a/src/lastdose.cpp b/src/lastdose.cpp
index 3462b43..0d8b6cd 100644
--- a/src/lastdose.cpp
+++ b/src/lastdose.cpp
@@ -57,7 +57,8 @@ Rcpp::List lastdose_impl(Rcpp::NumericVector id,
Rcpp::NumericVector fill,
Rcpp::LogicalVector back_calc,
Rcpp::LogicalVector sort1,
- Rcpp::LogicalVector comment) {
+ Rcpp::LogicalVector comment,
+ bool fill_comment_na) {
bool use_comp1 = sort1[0];
bool use_fill = !back_calc[0];
@@ -167,7 +168,7 @@ Rcpp::List lastdose_impl(Rcpp::NumericVector id,
last_time = it->time;
}
if(it->from_data) {
- if(it->comment) {
+ if(it->comment && fill_comment_na) {
tad[it->pos] = NA_REAL;
ldos[it->pos] = NA_REAL;
continue;
diff --git a/tests/testthat/test-lastdose.R b/tests/testthat/test-lastdose.R
index 9a430d6..5c5929e 100644
--- a/tests/testthat/test-lastdose.R
+++ b/tests/testthat/test-lastdose.R
@@ -128,6 +128,9 @@ test_that("commented records", {
set1[["addl"]] <- 0
set1[["C"]][10] <- "C"
ans <- lastdose(set1)
+ diff <- ans[["time"]] - ans[["TAD"]]
+ expect_equal(sum(diff),0)
+ ans <- lastdose(set1, fill_comments_na = TRUE)
expect_true(is.na(ans$TAD[10]))
expect_true(is.na(ans$LDOS[10]))
diff <- ans[["time"]] - ans[["TAD"]]
From 5ca83341cf871054af3b9b7f558ef24d699904ae Mon Sep 17 00:00:00 2001
From: Kyle Baron
Date: Fri, 31 Jan 2020 08:29:18 -0600
Subject: [PATCH 12/17] walk back argument to fill in commented records with NA
#8
---
R/RcppExports.R | 4 ++--
R/lastdose.R | 13 +++----------
README.md | 4 ++--
docs/index.html | 4 ++--
docs/reference/lastdose.html | 9 +++++++--
man/lastdose.Rd | 11 ++---------
src/RcppExports.cpp | 9 ++++-----
src/lastdose.cpp | 11 ++---------
tests/testthat/test-lastdose.R | 5 -----
9 files changed, 24 insertions(+), 46 deletions(-)
diff --git a/R/RcppExports.R b/R/RcppExports.R
index f2ab877..992d871 100644
--- a/R/RcppExports.R
+++ b/R/RcppExports.R
@@ -1,7 +1,7 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
-lastdose_impl <- function(id, time, amt, evid, addl, ii, fill, back_calc, sort1, comment, fill_comment_na) {
- .Call(`_lastdose_lastdose_impl`, id, time, amt, evid, addl, ii, fill, back_calc, sort1, comment, fill_comment_na)
+lastdose_impl <- function(id, time, amt, evid, addl, ii, fill, back_calc, sort1, comment) {
+ .Call(`_lastdose_lastdose_impl`, id, time, amt, evid, addl, ii, fill, back_calc, sort1, comment)
}
diff --git a/R/lastdose.R b/R/lastdose.R
index 72a9532..0b52f48 100644
--- a/R/lastdose.R
+++ b/R/lastdose.R
@@ -27,10 +27,6 @@ NULL
#' @param ... arguments passed to [lastdose_list]
#' @param include_ldos `logical`; if `FALSE` then the `LDOS` data is not
#' appended to the data set. Only used for the [lastdose] function.
-#' @param fill_comments_na if `TRUE`, then `TAD` and `LDOS` will be filled with
-#' `NA` when the comment indicator is `TRUE`; otherwise, commented records
-#' are filled in with the time since and amount of the dose on the last
-#' non-commented dosing record (the default).
#'
#' @details
#'
@@ -47,8 +43,7 @@ NULL
#' (as indicated with the `comments` argument) will never be considered as
#' actual doses when determining `TAD` and `LDOS`. But commented records (doses
#' and non-doses) will be assigned `TAD` and `LDOS` according to the last
-#' non-commented dosing record by default. The behavior can be modified by
-#' setting through the `fill_comments_na` argument.
+#' non-commented dosing record.
#'
#' **Additional notes**:
#'
@@ -104,8 +99,7 @@ lastdose <- function(data,..., include_ldos = TRUE) {
#' @export
lastdose_list <- function(data, fill = -99, back_calc = TRUE,
addl_ties = c("obs_first", "dose_first"),
- comments = find_comments(data),
- fill_comments_na = FALSE) {
+ comments = find_comments(data)) {
if(length(comments)==1) {
comments <- rep(comments,nrow(data))
}
@@ -180,8 +174,7 @@ lastdose_list <- function(data, fill = -99, back_calc = TRUE,
fill,
back_calc,
sort1,
- comments,
- fill_comments_na
+ comments
)
ans
}
diff --git a/README.md b/README.md
index c4dc827..265151a 100644
--- a/README.md
+++ b/README.md
@@ -163,7 +163,7 @@ system.time(x2 <- lastdose(big))
```
. user system elapsed
- . 0.049 0.001 0.051
+ . 0.045 0.002 0.048
## Compare against the single profile
@@ -172,7 +172,7 @@ system.time(x1 <- lastdose(df))
```
. user system elapsed
- . 0.000 0.000 0.001
+ . 0.001 0.000 0.000
``` r
x3 <- filter(x2, big[["ID"]]==1) %>% as.data.frame()
diff --git a/docs/index.html b/docs/index.html
index 68c7d5c..32f0870 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -181,14 +181,14 @@
a logcial vector with length equal to the number of rows
in data indicating which records are to be ignored when looking for TAD
-and LDOS.
+and LDOS. See all the fill_comments_na argument.
@@ -187,7 +187,12 @@
Details
When calling lastdose_list or lastdose_df, the respective items are
accessible with tad and ldos (note the lower case form here to
distinguish from the columns that might be added to the data frame).
-
Additional notes regarding behavior:
+
Handling of commented records: Dosing records that have been "commented"
+(as indicated with the comments argument) will never be considered as
+actual doses when determining TAD and LDOS. But commented records (doses
+and non-doses) will be assigned TAD and LDOS according to the last
+non-commented dosing record.
+
Additional notes:
All functions require an input data set as a data frame
The data set should be formatted according to NMTRAN type
conventions
diff --git a/man/lastdose.Rd b/man/lastdose.Rd
index f4ac70a..5d405ed 100644
--- a/man/lastdose.Rd
+++ b/man/lastdose.Rd
@@ -13,8 +13,7 @@ lastdose_list(
fill = -99,
back_calc = TRUE,
addl_ties = c("obs_first", "dose_first"),
- comments = find_comments(data),
- fill_comments_na = FALSE
+ comments = find_comments(data)
)
lastdose_df(data, ...)
@@ -45,11 +44,6 @@ details.}
\item{comments}{a logcial vector with length equal to the number of rows
in \code{data} indicating which records are to be ignored when looking for \code{TAD}
and \code{LDOS}. See all the \code{fill_comments_na} argument.}
-
-\item{fill_comments_na}{if \code{TRUE}, then \code{TAD} and \code{LDOS} will be filled with
-\code{NA} when the comment indicator is \code{TRUE}; otherwise, commented records
-are filled in with the time since and amount of the dose on the last
-non-commented dosing record (the default).}
}
\description{
Use \link{lastdose} to add (or potentially replace) columns to the input
@@ -70,8 +64,7 @@ distinguish from the columns that might be added to the data frame).
(as indicated with the \code{comments} argument) will never be considered as
actual doses when determining \code{TAD} and \code{LDOS}. But commented records (doses
and non-doses) will be assigned \code{TAD} and \code{LDOS} according to the last
-non-commented dosing record by default. The behavior can be modified by
-setting through the \code{fill_comments_na} argument.
+non-commented dosing record.
\strong{Additional notes}:
\itemize{
diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp
index d4b2aa7..b315baa 100644
--- a/src/RcppExports.cpp
+++ b/src/RcppExports.cpp
@@ -6,8 +6,8 @@
using namespace Rcpp;
// lastdose_impl
-Rcpp::List lastdose_impl(Rcpp::NumericVector id, Rcpp::NumericVector time, Rcpp::NumericVector amt, Rcpp::NumericVector evid, Rcpp::NumericVector addl, Rcpp::NumericVector ii, Rcpp::NumericVector fill, Rcpp::LogicalVector back_calc, Rcpp::LogicalVector sort1, Rcpp::LogicalVector comment, bool fill_comment_na);
-RcppExport SEXP _lastdose_lastdose_impl(SEXP idSEXP, SEXP timeSEXP, SEXP amtSEXP, SEXP evidSEXP, SEXP addlSEXP, SEXP iiSEXP, SEXP fillSEXP, SEXP back_calcSEXP, SEXP sort1SEXP, SEXP commentSEXP, SEXP fill_comment_naSEXP) {
+Rcpp::List lastdose_impl(Rcpp::NumericVector id, Rcpp::NumericVector time, Rcpp::NumericVector amt, Rcpp::NumericVector evid, Rcpp::NumericVector addl, Rcpp::NumericVector ii, Rcpp::NumericVector fill, Rcpp::LogicalVector back_calc, Rcpp::LogicalVector sort1, Rcpp::LogicalVector comment);
+RcppExport SEXP _lastdose_lastdose_impl(SEXP idSEXP, SEXP timeSEXP, SEXP amtSEXP, SEXP evidSEXP, SEXP addlSEXP, SEXP iiSEXP, SEXP fillSEXP, SEXP back_calcSEXP, SEXP sort1SEXP, SEXP commentSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
@@ -21,14 +21,13 @@ BEGIN_RCPP
Rcpp::traits::input_parameter< Rcpp::LogicalVector >::type back_calc(back_calcSEXP);
Rcpp::traits::input_parameter< Rcpp::LogicalVector >::type sort1(sort1SEXP);
Rcpp::traits::input_parameter< Rcpp::LogicalVector >::type comment(commentSEXP);
- Rcpp::traits::input_parameter< bool >::type fill_comment_na(fill_comment_naSEXP);
- rcpp_result_gen = Rcpp::wrap(lastdose_impl(id, time, amt, evid, addl, ii, fill, back_calc, sort1, comment, fill_comment_na));
+ rcpp_result_gen = Rcpp::wrap(lastdose_impl(id, time, amt, evid, addl, ii, fill, back_calc, sort1, comment));
return rcpp_result_gen;
END_RCPP
}
static const R_CallMethodDef CallEntries[] = {
- {"_lastdose_lastdose_impl", (DL_FUNC) &_lastdose_lastdose_impl, 11},
+ {"_lastdose_lastdose_impl", (DL_FUNC) &_lastdose_lastdose_impl, 10},
{NULL, NULL, 0}
};
diff --git a/src/lastdose.cpp b/src/lastdose.cpp
index 0d8b6cd..58c456d 100644
--- a/src/lastdose.cpp
+++ b/src/lastdose.cpp
@@ -57,8 +57,7 @@ Rcpp::List lastdose_impl(Rcpp::NumericVector id,
Rcpp::NumericVector fill,
Rcpp::LogicalVector back_calc,
Rcpp::LogicalVector sort1,
- Rcpp::LogicalVector comment,
- bool fill_comment_na) {
+ Rcpp::LogicalVector comment) {
bool use_comp1 = sort1[0];
bool use_fill = !back_calc[0];
@@ -167,13 +166,7 @@ Rcpp::List lastdose_impl(Rcpp::NumericVector id,
last_dose = it->amt;
last_time = it->time;
}
- if(it->from_data) {
- if(it->comment && fill_comment_na) {
- tad[it->pos] = NA_REAL;
- ldos[it->pos] = NA_REAL;
- continue;
- }
- if(had_dose) {
+ if(it->from_data) { if(had_dose) {
tad[it->pos] = it->time - last_time;
} else {
tad[it->pos] = (use_fill || no_dose) ? fill[0] : (it->time - tofd[i]);
diff --git a/tests/testthat/test-lastdose.R b/tests/testthat/test-lastdose.R
index 5c5929e..3aa4f03 100644
--- a/tests/testthat/test-lastdose.R
+++ b/tests/testthat/test-lastdose.R
@@ -130,11 +130,6 @@ test_that("commented records", {
ans <- lastdose(set1)
diff <- ans[["time"]] - ans[["TAD"]]
expect_equal(sum(diff),0)
- ans <- lastdose(set1, fill_comments_na = TRUE)
- expect_true(is.na(ans$TAD[10]))
- expect_true(is.na(ans$LDOS[10]))
- diff <- ans[["time"]] - ans[["TAD"]]
- expect_equal(sum(diff,na.rm=TRUE),0)
expect_error(lastdose(set1, comments = c(FALSE, TRUE,FALSE)))
})
From 5cca89abdae93aec5b916665598a9861dc2dec82 Mon Sep 17 00:00:00 2001
From: Kyle Baron
Date: Sat, 1 Feb 2020 07:41:35 -0600
Subject: [PATCH 13/17] site; add _pkgdown.yml
---
_pkgdown.yml | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 _pkgdown.yml
diff --git a/_pkgdown.yml b/_pkgdown.yml
new file mode 100644
index 0000000..c4e25ab
--- /dev/null
+++ b/_pkgdown.yml
@@ -0,0 +1,2 @@
+development:
+ mode: auto
From cd84466312b2e4ab2be2fd6daf1badb12449986d Mon Sep 17 00:00:00 2001
From: Kyle Baron
Date: Sat, 1 Feb 2020 07:45:22 -0600
Subject: [PATCH 14/17] update news
---
NEWS.md | 5 +++++
docs/news/index.html | 8 ++++++++
2 files changed, 13 insertions(+)
diff --git a/NEWS.md b/NEWS.md
index ada024b..61c1f81 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,4 +1,9 @@
+# lastdose 0.2.0
+- Commented records are not considered when looking for doses in the data set,
+ but `TAD` and `LDOS` are filled like any other observation record (relative
+ to the last no-commented dose) #9
+
# lastdose 0.1.0
- Update git origin
diff --git a/docs/news/index.html b/docs/news/index.html
index 0db66c2..5b3ae49 100644
--- a/docs/news/index.html
+++ b/docs/news/index.html
@@ -110,6 +110,13 @@
Commented records are not considered when looking for doses in the data set, but TAD and LDOS are filled like any other observation record (relative to the last no-commented dose) #9
Commented records are not considered when looking for doses in the data set, but TAD and LDOS are filled like any other observation record (relative to the last no-commented dose) #9
+
Commented records are not considered when looking for doses in the data set, but TAD and LDOS are filled like any other observation record (relative to the last non-commented dose) #9