Calculate Body Weight Z-score for a given STUDYID from SQLite Database or .xpt
Files
Source: R/get_bw_score.R
get_bw_score.Rd
The get_bw_score
function calculates the Body Weight (BW) Z-score for a specified STUDYID using data from a provided database or .xpt files.
It supports optional parameters to customize the analysis and offers the flexibility to return individual Z-score by USUBJID
(unique subject identifier).
Usage
get_bw_score(
studyid = NULL,
path_db,
fake_study = FALSE,
use_xpt_file = FALSE,
master_compiledata = NULL,
return_individual_scores = FALSE,
return_zscore_by_USUBJID = FALSE
)
Arguments
- studyid
Character. STUDYID number. Defaults to
NULL
. Required for SQLite databases (use_xpt_file = FALSE
). Must beNULL
for.xpt
files (use_xpt_file = TRUE
).- path_db
Character. Path to the SQLite database file or a folder containing
.xpt
files. Mandatory.- fake_study
Logical. Whether the study data is generated by the
SENDsanitizer
package. Defaults toFALSE
.- use_xpt_file
Logical. Whether to retrieve study data from
.xpt
files instead of the SQLite database. Defaults toFALSE
.- master_compiledata
Optional, character
Ifmaster_compiledata
is not supplied (i.e.,NULL
), the function will automatically call theget_compile_data
function to calculate it.- return_individual_scores
Optional, logical
If TRUE, the function returns individual scores for each domain by averaging the scores of all subjects/animals (USUBJID
) in the study. Default isFALSE
.- return_zscore_by_USUBJID
Optional, logical
IfTRUE
, the function returns Z-scores for each animal/subject byUSUBJID
. Default isFALSE
.
Value
A data.frame
containing the calculated BW Z-scores. The structure of the output depends on the provided parameters:
If
return_individual_scores = TRUE
: Returns averaged Z-scores for each domain perstudyid
.If
return_zscore_by_USUBJID = TRUE
: Returns Z-score for each animal/subject byUSUBJID
for each domain perstudyid
.Otherwise, a summarized BW score for the specified
studyid
.
Examples
if (FALSE) { # \dontrun{
# Example 1: Basic usage
get_bw_score(studyid = '1234123', path_db = 'path/to/database.db')
# Example 2: Include individual scores
get_bw_score(studyid = '1234123', path_db = 'path/to/database.db', return_individual_scores = TRUE)
# Example 3: Include z-scores by USUBJID
get_bw_score(studyid = '1234123', path_db = 'path/to/database.db', return_zscore_by_USUBJID = TRUE)
} # }