Learn R Programming

invivoPKfit (version 2.0.1)

check_newdata: Check new data

Description

Check new data to ensure it has the required variables and classes

Usage

check_newdata(newdata, olddata, req_vars, exclude = FALSE)

Value

`TRUE`, if required variables are present in `newdata`, and required variables are of the same class in `newdata` and `olddata`. Otherwise, this function will stop with an error.

Arguments

newdata

A `data.frame` containing new data

olddata

A `data.frame` containing existing data. `newdata` variable classes will be required to match `olddata`

req_vars

A `character` vector of required variable names that must appear in `newdata`

exclude

Logical: Whether a variable `"exclude"` also must be present in `newdata`

Author

Caroline Ring

Details

This is a helper function to check new data to ensure it has the required variables and that those variables are of the correct classes. This is useful, for example, when making predictions from a fitted [pk()] model object on new data.