View source: R/R04-Data_wrangling.R
camr_unique_values | R Documentation |
Function that filters out missing values and propagates the unique values associated with distinct cases in an index column. Useful, for example, taking values (like participant characteristics) that were collected at a single time point and propagating them across all time points.
camr_unique_values(
dtf,
index,
variables,
default = NA,
propagate = TRUE,
first = TRUE,
warn_if_multiple = TRUE
)
dtf |
A data frame. |
index |
The column in |
variables |
A character vector, all columns in
|
default |
The default value to return if unique values are missing. |
propagate |
A logical value; if |
first |
A logical value; if |
warn_if_multiple |
A logical value; if |
A vector of unique values associated with the
distinct cases in index
.
Kevin Potter
data( example_CAM_data_set )
example_CAM_data_set |>
camr_unique_values(
IDS.INT.Screening,
"SBJ.INT.Age"
)
example_CAM_data_set |>
camr_unique_values(
IDS.INT.Screening,
"SBJ.INT.Age",
propagate = FALSE
)
# Can extract values over multiple columns
example_CAM_data_set |>
camr_unique_values(
IDS.INT.Screening,
c( "SBJ.INT.Age", "SBJ.INT.Age_at_visit_1" ),
propagate = FALSE,
warn_if_multiple = FALSE
)
# If 'warn_if_multiple' was TRUE function
# would appropriately generate warning for
# 3rd individual who has different ages
# recorded across variables
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.