Joins the simulation and input data of a bbi_nonmem_model
object with an
attached simulation.
nm_join_sim(
.mod,
.join_col = "NUM",
.cols_keep = "all",
add_table_names = FALSE
)
A bbi_nonmem_model
with an attached simulation, or a
bbi_nmsim_model
object.
Character column name(s) to use to join table files.
Defaults to NUM
. See Details.
Either 'all'
, or a vector of column name(s) to retain
in the final dataset after joining. Defaults to keeping all columns.
Logical (T/F). If TRUE
, include a column denoting
the table names as specified in the file (e.g., 'TABLE NO. 1'
).
a tibble
The join column name(s) specified should match what you provided to
add_simulation()
.
The .join_col
is the name of a single column that should appear in both the
input data set and any tables you want to join. We recommend you make this
column a simple integer numbering the rows in the input data set (for example
NUM
). When this column is carried into the output table files, there will
be unambiguous matching from the table file back to the input data set.
Note also that, when .join_col
is carried into table outputs, there is no
need to table any other columns from the input data as long as the
nm_join()
approach is used; any column in the input data set, regardless
of whether it is listed in $INPUT
or not, will be carried through from the
input data and therefore available in the joined result.
Duplicate Rows Warning for Join Column
If there are duplicate rows found in the specified .join_col
, a warning
will be raised specifying a subset of the repeated rows. Duplicates may be
caused by lack of output width. FORMAT
may be need to be stated in control
stream to have sufficient width to avoid truncating .join_col
.
.join_col
Take the following $INPUT
and $DATA
records:
Before submitting a model, read in the data and add a row number column;
library(dplyr)
data <- nm_data(.mod) %>% mutate(NUM = 1:n())
readr::write_csv(data, get_data_path(.mod))
Then add 'NUM'
to the list of input columns:
if (FALSE) {
add_simulation(.mod, .join_col = c("NUM", "ID"))
nm_join_sim(.mod, .join_col = c("NUM", "ID"), .cols_keep = "ID")
# These return the same thing (simulation model is automatically read-in):
nm_join_sim(.mod)
nm_join_sim(get_simulation(.mod))
}