PreviousResult {Transition}R Documentation

Find Previous Test Result for Subject

Description

get_prev_results() identifies the previous test result for individual subjects and timepoints in a longitudinal study.

add_prev_result() interpolates these previous test results into a data frame for further analysis.

Usage

add_prev_result(
  object,
  subject = "subject",
  timepoint = "timepoint",
  result = "result"
)

get_prev_result(
  object,
  subject = "subject",
  timepoint = "timepoint",
  result = "result"
)

Arguments

object

a data.frame (or object coercible by as.data.frame() to a data frame) containing the data to be analysed.

subject

character, name of the column (of type integer or factor) identifying individual study subjects; default "subject".

timepoint

character, name of the column recording time points (as Dates) of testing of subjects; default "timepoint".

result

character, name of the column (of type ordered factor) recording test results; default "result".

Details

See Transitions details.

Value

add_prev_result()

A data.frame based on object, with an added column of type ordered factor containing the values of the previous test results.

get_prev_result()

An ordered factor of length nrow(object), containing the values of the previous test results ordered in the exact sequence of the subject and timepoint in object.

See Also

data.frame, Dates, ordered factor.

Other transitions: PreviousDate, Transitions, uniques()

Examples




 ## Continuing example from `add_transitions()`
  # subject, timepoint and result arguments all defaults and required types
Blackmore |> str()

  # Previous test results as ordered factor
get_prev_result(Blackmore)

  # Previous test result as column of data frame
(Blackmore <- add_prev_result(Blackmore)) |> head(32)

rm(Blackmore)


[Package Transition version 1.0.0 Index]