filterData {patientProfilesVis}R Documentation

Filter a dataset for records of interest, for use in the patient profiles.

Description

Data is filtered based on the following workflow:

  1. The subset dataset (of data if not specified) is filtered based on subject variable and value (if specified).

  2. If a external subset dataset is specified, only the subject IDs of this filtered dataset are considered.

  3. The data is filtered based on the selected subjects, from subjectSubset (if specified) or from step 2.

  4. The data is filtered based on a random selection of subjects, if subjectSample is specified.

This filtering workflow is used for all subject profile visualization functions of the package.

Usage

filterData(
  data,
  subsetData = NULL,
  subsetVar = NULL,
  subsetValue = NULL,
  subjectVar = "USUBJID",
  subjectSubset = NULL,
  subjectSample = NULL,
  seed = 123
)

Arguments

data

Data.frame with data

subsetData

(optional) Data.frame with extra dataset to filter on. This dataset is filtered, and only records from data with common subject IDs will be retained.
If not specified, data is used.

subsetVar

(optional) String with variable of subset data to filter on. subsetValue should be specified too.
If not specified, all records from the subset data are retained.

subsetValue

(optional) Character vector with value(s) of interest to retain in the filtered data. These values should be available in subsetVar.
Missing values in the subject variable are not retained in the filtered data.

subjectVar

String, variable of data (and subset data) with subject ID.

subjectSubset

(optional) Character vector with subjects of interest (available in subjectVar), NULL by default.

subjectSample

(optional) Integer of length 1 with number of random subject(s) that should be considered, e.g. to check the created patient profiles for a subset of the data. By default, all specified subjects are considered (set to NULL).

seed

(optional) Integer of length 1 with seed used to select random subjects if subjectSample is specified (123 by default).

Value

possibly filtered dataset

Author(s)

Laure Cougnaud

Examples

library(clinUtils)

data(dataSDTMCDISCP01)
dataAll <- dataSDTMCDISCP01

# keep only a subset of subjects
# (e.g. to visualize specified patient profiles
# before creating them for all subject)
filterData(
	data = dataAll$AE,
	subjectSample = 2
)

# filter based on specified variable/value:
# only adverse events possibly related
filterData(
	data = dataAll$AE,
	subsetVar = "AEREL",
	subsetValue = "POSSIBLE"
)

# filter based on a different dataset:
# keep only adverse events for subjects in a specific treatment arm
filterData(
	data = dataAll$AE,
	subsetData = dataAll$DM,
	subsetVar = "ACTARM",
	subsetValue = "Placebo"
)

# filter based on subjects of interest
filterData(
	data = dataAll$AE,
	subjectSubset = c("01-701-1148", "01-701-1211")
)


[Package patientProfilesVis version 2.0.9 Index]