Skip to content

Commit

Permalink
Restored npde function
Browse files Browse the repository at this point in the history
  • Loading branch information
mnneely committed Jun 12, 2020
1 parent d4f7a21 commit e874386
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 27 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Description: Parametric and non-parametric
which used to be available on CRAN.
Authors@R: person("Michael", "Neely",
email = "[email protected]", role = c("aut", "cre"))
Version: 1.9.6
Version: 1.9.7
URL: http://www.lapk.org
Date: 2020-06-09
Date: 2020-06-12
Depends:
R (>= 3.5.0)
Imports:
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export(setPMoptions)
export(ss.PK)
export(update_gfortran)
importFrom(base64enc,base64decode)
importFrom(dplyr,arrange)
importFrom(cubelyr,as.tbl_cube)
importFrom(dplyr,arrange)
importFrom(dplyr,filter)
importFrom(dplyr,mutate)
importFrom(dplyr,select)
Expand Down
9 changes: 7 additions & 2 deletions R/PMutilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -2005,7 +2005,7 @@ getOSname <- function() {

# check for installed packages --------------------------------------------

checkRequiredPackages <- function(pkg) {
checkRequiredPackages <- function(pkg, repos="CRAN") {

managePkgs <- function(thisPkg) {
# if (length(grep(thisPkg, installed.packages()[, 1])) == 0) {
Expand All @@ -2014,7 +2014,12 @@ checkRequiredPackages <- function(pkg) {
if (requireNamespace(thisPkg, quietly = T)) {
return("ok") #package is installed
} else { #package is not installed
install.packages(thisPkg, dependencies = T, quiet = T) #try to install
cat(paste0("The package ",thisPkg," is required and will be installed.\n"))
if(repos == "CRAN"){
install.packages(thisPkg, dependencies = T, quiet = T) #try to install
}else{
devtools::install_github(repos)
}
if (requireNamespace(thisPkg, quietly = T)){ #check again
return("ok") #now it is installed and ok
} else {return(thisPkg) } #nope, still didn't install
Expand Down
41 changes: 22 additions & 19 deletions R/makeValid.R
Original file line number Diff line number Diff line change
Expand Up @@ -427,25 +427,28 @@ makeValid <- function(run,input=1,outeq=1,tad=F,binCov,doseC,timeC,tadC,...){
#NPDE --------------------------------------------------------------------

#temporarily disable NPDE until we can clean code 3/9/2020
npdeRes <- NA

# #prepare data for npde
# obs <- tempDF[tempDF$icen=="mean",c("id","time","obs")]
#
# #remove missing obs
# obs <- obs[obs$obs!=-99,]
# names(obs)[3] <- "out"
#
# simobs <- simFull$obs
# #remove missing simulations
# simobs <- simobs[simobs$out!=-99,]
# simobs$id <- rep(obs$id,each=nsim)
#
# #get NPDE
# assign("thisobs",obs,pos=1)
# assign("thissim",simobs,pos=1)
# npdeRes <- tryCatch(autonpde(namobs=thisobs,namsim=thissim,1,2,3,verbose=T),error=function(e) e)
#
#npdeRes <- NA

#get npde from github
checkRequiredPackages("npde", repos = "LAPKB/npde")

#prepare data for npde
obs <- tempDF[tempDF$icen=="mean",c("id","time","obs")]

#remove missing obs
obs <- obs[obs$obs!=-99,]
names(obs)[3] <- "out"

simobs <- simFull$obs
#remove missing simulations
simobs <- simobs[simobs$out!=-99,]
simobs$id <- rep(obs$id,each=nsim)

#get NPDE
assign("thisobs",obs,pos=1)
assign("thissim",simobs,pos=1)
npdeRes <- tryCatch(npde::autonpde(namobs=thisobs,namsim=thissim,1,2,3,verbose=T),error=function(e) e)




Expand Down
7 changes: 4 additions & 3 deletions R/plotPMvalid.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ plot.PMvalid <- function(x,type="vpc",tad=F,icen="median",outeq=1,lower=0.025,up
}

if(type=="npde"){
cat("NPDE temporarily disabled pending code cleaning.\n")
# plot(x$npde)
# par(mfrow=c(1,1))
#cat("NPDE temporarily disabled pending code cleaning.\n")
if(is.null(x$npde)) stop("No npde object found. Re-run makeValid.\n")
plot(x$npde)
par(mfrow=c(1,1))
}

}
29 changes: 29 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
\name{NEWS}
\title{NEWS file for the Pmetrics package}
\section{Changes in version 1.9.7}{

\subsection{NEW FEATURES}{
\itemize{
\item Restored npde function by creating new git npde repository
}
}
\subsection{BUG FIXES}{
\itemize{
\item None
}
}
}


\section{Changes in version 1.9.6}{

\subsection{NEW FEATURES}{
\itemize{
\item None
}
}
\subsection{BUG FIXES}{
\itemize{
\item Fixed error in makePost associated with conversion to tidyverse handling
}
}
}


\section{Changes in version 1.9.5}{

Expand Down

0 comments on commit e874386

Please sign in to comment.