Learn R Programming

Transition (version 1.0.2)

uniques: Unique Values for Subject, Timepoint and Result

Description

uniques() identifies unique values for subjects, timepoints and test results in longitudinal study data.

Usage

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

Value

A list of three elements

1.

An integer vector or factor of unique subject identifications.

2.

A vector of class Date of unique timepoints in the study.

3.

An ordered factor of unique values for results of the study.

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, or binary, see Details) recording test results; default "result".

Details

See Transitions details.

Works for subject as either an integer vector or a factor.

See Also

data.frame, Dates, ordered factor.

Other transitions: PreviousDate, PreviousResult, Transitions

Examples

Run this code

# \dontshow{
Blackmore <- transform(Blackmore, timepoint = as.Date("2000-01-01") + round(age * 365.25),
    result = cut(exercise, breaks = seq(0, 30, 2), labels = paste0("<=", seq(0, 30, 2)[-1]),
        include.lowest = TRUE, ordered_result = TRUE))
# }

 ## Continuing example from `add_transitions()`
  # subject, timepoint and result arguments all defaults and required types
  # (native subject is factor)
uniques(Blackmore)
  #
Blackmore <- transform(Blackmore, subject = as.integer(subject))
  # subject now as integer
Blackmore |> str()
uniques(Blackmore)

rm(Blackmore)

Run the code above in your browser using DataLab