-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marie-Laure DELIGNETTE-MULLER
committed
Nov 20, 2023
1 parent
30f1457
commit 453c7f3
Showing
5 changed files
with
65 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 18 additions & 18 deletions
36
share/techdoc/functions2add/selectitems.R → R/selectitems.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,65 @@ | ||
selectitems <- function(extendedres, | ||
selectitems <- function(res, | ||
BMDfilter = c("definedCI", "finiteCI", "definedBMD", "none"), | ||
BMDtype = c("zSD", "xfold") | ||
) | ||
{ | ||
if (missing(extendedres) | !is.data.frame(extendedres)) | ||
if (missing(res) | !is.data.frame(res)) | ||
stop("The first argument of selectitems must be a dataframe | ||
(see ?selectitems for details).") | ||
|
||
BMDfilter <- match.arg(BMDfilter, c("definedCI", "finiteCI", "definedBMD", "none")) | ||
BMDtype <- match.arg(BMDtype, c("zSD", "xfold")) | ||
cnames <- colnames(extendedres) | ||
cnames <- colnames(res) | ||
|
||
# Definition of the filter to apply | ||
if ((BMDtype == "zSD") & (BMDfilter != "none")) | ||
{ | ||
if (any(!is.element(c("BMD.zSD"), cnames))) | ||
stop("The first argument of selectitems must be a dataframe | ||
containing at least columns named id and BMD.zSD.") | ||
BMD <- extendedres$BMD.zSD | ||
containing a column named BMD.zSD.") | ||
BMD <- res$BMD.zSD | ||
if ((BMDfilter == "definedCI") | (BMDfilter == "finiteCI")) | ||
{ | ||
if (any(!is.element(c("BMD.zSD.upper", "BMD.zSD.lower"), cnames)) ) | ||
stop("To apply a filter on BMD.zSD confidence intervals, the first argument of selectitems | ||
must be a dataframe containing at least columns named id and BMD.zSD, BMD.zSD.lower, BMD.zSD.upper.") | ||
BMDupper <- extendedres$BMD.zSD.upper | ||
BMDlower <- extendedres$BMD.zSD.lower | ||
must be a dataframe containing columns named BMD.zSD, BMD.zSD.lower, BMD.zSD.upper.") | ||
BMDupper <- res$BMD.zSD.upper | ||
BMDlower <- res$BMD.zSD.lower | ||
} | ||
} else #so if (BMDtype == "xfold") | ||
if ((BMDtype == "xfold") & (BMDfilter != "none")) | ||
{ | ||
if (any(!is.element(c("BMD.xfold"), cnames))) | ||
stop("The first argument of selectitems must be a dataframe | ||
containing at least columns named id and BMD.xfold.") | ||
BMD <- extendedres$BMD.xfold | ||
containing a column named BMD.xfold.") | ||
BMD <- res$BMD.xfold | ||
if ((BMDfilter == "definedCI") | (BMDfilter == "finiteCI")) | ||
{ | ||
if (any(!is.element(c("BMD.xfold.upper","BMD.xfold.lower"), cnames))) | ||
stop("To apply a filter on BMD.xfold confidence intervals, the first argument of selectitems | ||
must be a dataframe containing at least columns named id and BMD.xfold, BMD.xfold.lower, BMD.xfold.upper.") | ||
BMDupper <- extendedres$BMD.xfold.upper | ||
BMDlower <- extendedres$BMD.xfold.lower | ||
must be a dataframe containing columns named BMD.xfold, BMD.xfold.lower, BMD.xfold.upper.") | ||
BMDupper <- res$BMD.xfold.upper | ||
BMDlower <- res$BMD.xfold.lower | ||
} | ||
} | ||
|
||
# Filtering | ||
if (BMDfilter == "definedCI") | ||
{ | ||
subextendedres <- extendedres[!is.na(BMD) & !is.na(BMDupper) & !is.na(BMDlower), ] | ||
subres <- res[!is.na(BMD) & !is.na(BMDupper) & !is.na(BMDlower), ] | ||
} else | ||
if (BMDfilter == "finiteCI") | ||
{ | ||
subextendedres <- extendedres[is.finite(BMD) & is.finite(BMDupper) & is.finite(BMDlower), ] | ||
subres <- res[is.finite(BMD) & is.finite(BMDupper) & is.finite(BMDlower), ] | ||
} else | ||
if (BMDfilter == "definedBMD") | ||
{ | ||
subextendedres <- extendedres[!is.na(BMD), ] | ||
subres <- res[!is.na(BMD), ] | ||
} else | ||
if (BMDfilter == "none") | ||
{ | ||
subextendedres <- extendedres | ||
subres <- res | ||
} | ||
return(subextendedres) | ||
return(subres) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters