Skip to content

Commit f273186

Browse files
committed
example fix and more Rdevel data.table fixes
1 parent b593dbd commit f273186

6 files changed

Lines changed: 14 additions & 10 deletions

File tree

R/NMcheckData.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,10 +896,11 @@ NMcheckData <- function(data,file,covs,covs.occ,cols.num,col.id="ID",
896896

897897
######## End Default columns
898898

899-
899+
900900
## ID-level checks
901901
### Warning if the same ID is in non-consequtive rows
902-
data[,ID.jump:=c(0,diff(get(rowint))),by=col.id]
902+
##data[,ID.jump:=c(0,diff(get(rowint))),by=col.id]
903+
data[,ID.jump:=c(0,diff(.SD[[rowint]])),by=col.id]
903904
findings <- listEvents("ID.jump",colname=col.id,name="ID disjoint",fun=function(x) x<=1,events=findings,debug=FALSE)
904905

905906

R/NMgenText.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,11 @@ NMgenText <- function(data,
231231
warning("No columns to use in Nonmem. Did you forget to order or drop columns")
232232
return(NULL)
233233
}
234+
234235

235-
dt.num.ok[include==TRUE,occ.cum:=1:.N,by=name.nm]
236+
## dt.num.ok[include==TRUE,occ.cum:=1:.N,by=name.nm]
237+
dt.num.ok[,occ.cum:=1:.N,by=name.nm]
238+
dt.num.ok[include!=TRUE,occ.cum:=NA_real_]
236239
if(dt.num.ok[occ.cum>1,.N]>0) {
237240
warning(paste("Duplicated column name(s) in data for Nonmem:\n",
238241
paste0(dt.num.ok[occ.cum>1,unique(name.nm)],collapse=", "),"\n",

R/NMrelateOne.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ NMrelateOne <- function(file,lines,par.type="OMEGA",sections=c("PRED","PK","ERRO
5050
lines.list <- lines.list[names(lines.list)%in%sections]
5151
## lines <- do.call(c,lines.list)
5252
lines <- unlist(lines.list)
53-
53+
5454
dt.code <- data.table(line.var = lines[grepl(str.regex.find,lines,ignore.case=TRUE)])
5555

5656
if(is.null(dt.code) || nrow(dt.code)==0) return(NULL)
@@ -73,7 +73,7 @@ NMrelateOne <- function(file,lines,par.type="OMEGA",sections=c("PRED","PK","ERRO
7373

7474

7575
dt.code[var.type%in%c("ETA","THETA","ERR","EPS"),
76-
i:=as.numeric(sub(paste0(".*",var.type,"\\(([1-9][0-9]*)\\)"),"\\1",x=var.name,ignore.case=TRUE)),
76+
i:=as.numeric(sub(paste0(".*",first(var.type),"\\(([1-9][0-9]*)\\)"),"\\1",x=var.name,ignore.case=TRUE)),
7777
by=lineno]
7878

7979
dt.code[,j:=NA_integer_]

R/lapplydt.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
##' @import data.table
2121
##' @examples
2222
##' pk <- readRDS(file=system.file("examples/data/xgxr2.rds",package="NMdata"))
23-
##' lapplydt(pk,by="DOSE",fun=function(x) {
23+
##' lapplydt(pk,by="DOSE",fun=function(x,.nm) {
2424
##' message("this is subset",.nm)
25-
##' nrow(x)
25+
##' message(paste("Result:",nrow(x)))
2626
##' })
2727
##' @return a list
2828
##' @export

man/NMreadParsText.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/lapplydt.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)