clean_obs_data: Tidy up messy observed concentration-time data. UNDER...

View source: R/clean_obs_data.R

clean_obs_dataR Documentation

Tidy up messy observed concentration-time data. UNDER CONSTRUCTION!!!

Description

The function clean_obs_data is meant to perform the following automated data cleaning steps:

  1. Make all the main columns that you probably want in concentration-time data – Subject, Day, Time, DV, Conttime, etc. – be the 1st columns listed and have standardized names.

  2. Remove "mg" or "mg/kg" or "mg/m2" from any column with the dose info.

  3. If there's a column for the day and a column for the time, calculate the continuous time.

  4. Set any times < 0 to 0.

  5. Split the data into separate csv files or list items by user-specified columns.

A note: When you specify which columns are which in the arguments, the names must EXACTLY match what R reads in for an Excel file. This can be tricky if there are any spaces or especially any carriage returns in the column headings in an Excel file. Put tick marks around any column names with spaces or special characters, e.g., 'Subject ID'. clean_obs_data will not do everything you'll probably need since messy data are messy in their own unique ways in every case, but it will make a start. Once your observed concentration-time data are in good shape, we recommend checking out format_obs_for_XML for getting the data into the shape necessary for pasting into a Simcyp Simulator PE template Excel file, including adding dosing rows automatically based your specifications for the dosing interval.

Usage

clean_obs_data(
  untidy_data,
  untidy_data_sheet = NA,
  cohort_column,
  subject_column,
  time_column,
  DV_column,
  analyte_column,
  dose_column,
  day_column,
  age_column,
  weight_column,
  height_column,
  sex_column,
  SDSE_column,
  injection_site_column,
  dose_unit = "mg",
  weighting = 1,
  split_columns = NA,
  save_csv = NA
)

Arguments

untidy_data

a data.frame to be tidied or a csv file with the untidy data or an Excel file with the untidy data. This should be in quotes.

untidy_data_sheet

if you supplied an Excel file with the untidy data, specify what sheet to read here. This should be in quotes.

cohort_column

the column in the observed concentration-time data.frame that contains the cohorts, unquoted

subject_column

the column in the observed concentration-time data.frame that contains the subject IDs, unquoted.

time_column

the column in the untidy data.frame that contains times, unquoted.

DV_column

the column in the untidy data.frame that contains concentration data, unquoted.

analyte_column

the column in the untidy data.frame that contains the analytes, unquoted.

dose_column

the column in the untidy data.frame that contains the doses, unquoted.

day_column

the column in the untidy data.frame that contains the days, unquoted.

age_column

the column in the untidy data.frame that contains the ages, unquoted.

weight_column

the column in the untidy data.frame that contains the weights, unquoted.

height_column

the column in the untidy data.frame that contains heights, unquoted.

sex_column

the column in the untidy data.frame that contains sexes, unquoted.

SDSE_column

the column in the untidy data.frame that contains the standard deviation or standard error, unquoted.

injection_site_column

the column in the untidy data.frame that contains the injection site, unquoted.

dose_unit

the unit of dosing. Options are "mg" (default), "mg/m2", or "mg/kg".

weighting

weighting to use for parameter estimation. Defaults to 1.

split_columns

Which columns should the data be split up by? This should be quoted. Apologies for the difference here since the other column assignments are unquoted, but, since this can have multiple columns, the coding is easiest to do if these are in quotes. We're trying to figure out how to get around that.

save_csv

optionally specify a file name for saving the tidied data as a csv. If you have more than one dose level in the data, the files will be split up by dose level, and we'll include a suffix with the dose amount at the end of the file name.

Value

a list of tidied data, split by dose level

Examples

# none yet



shirewoman2/Consultancy documentation built on June 1, 2025, 6:05 p.m.