Skip to content

Commit

Permalink
bugfix in replacing first sections
Browse files Browse the repository at this point in the history
  • Loading branch information
philipdelff committed Dec 7, 2024
1 parent 29d0c1e commit 885da6b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: NMdata
Type: Package
Title: Preparation, Checking and Post-Processing Data for PK/PD Modeling
Version: 0.1.8.903
Version: 0.1.8.904
Authors@R:
c(person(given="Philip", family="Delff",
email = "philip@delff.dk",
Expand Down
2 changes: 0 additions & 2 deletions R/NMreadExt.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ NMreadExt <- function(file,return,as.fun,modelname,col.model,auto.ext,tableno="m
i==j|abs(value)>1e-9,.(iblock=min(i,j)),by=.(par.type,i)]
tab.i[,blocksize:=.N,by=.(par.type,iblock)]

## pars0 <- copy(pars)
## tab.blocks
pars <- mergeCheck(pars,tab.i,by=cc(par.type,i),all.x=T,quiet=TRUE)

## pars[par.type%in%c("OMEGA","SIGMA"),.(i,j,iblock,blocksize,value)]
Expand Down
11 changes: 8 additions & 3 deletions R/NMwriteSectionOne.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
##' @keywords internal

NMwriteSectionOne <- function(file0,lines,section,location="replace",
NMwriteSectionOne <- function(file0,lines,section,location=c("replace","before","after","first","last"),
newlines,list.sections,newfile,
backup=TRUE,blank.append=TRUE,write,
quiet=FALSE){

after <- NULL
before <- NULL
mad.dl <- NULL



location <- match.arg(location)

if(!missing(file0)){
file0 <- filePathSimple(file0)
stopifnot(file.exists(file0))
Expand Down Expand Up @@ -37,6 +41,7 @@ NMwriteSectionOne <- function(file0,lines,section,location="replace",

## put this part in a function to be sequentially applied for all elements in list.
replaceOnePart <- function(lines,section,newlines,quiet=FALSE){

if(!quiet && !is.null(newfile)) message(paste("Writing",newfile))

## make sure section is capital and does not start with $.
Expand Down Expand Up @@ -85,7 +90,7 @@ NMwriteSectionOne <- function(file0,lines,section,location="replace",
if(min.dl==1&&max.dl==nlines){
all.lines <- newlines
} else if(min.dl==1){
all.lines <- c(newlines,lines[(mad.dl+1),nlines])
all.lines <- c(newlines,lines[(max.dl+1):nlines])
} else if(max.dl==nlines){
all.lines <- c(lines[1:(min.dl-1)],newlines)
} else {
Expand Down

0 comments on commit 885da6b

Please sign in to comment.