Extract and Format the First N Unique Values from a Vector
first_n.RdThis function extracts the first N unique, non-missing values from a vector, formats them appropriately, and returns them as a truncated character string.
Arguments
- x
A vector of any type (numeric, character, factor, or Date).
- n
An integer specifying the number of unique values to return. Defaults to 5.
Value
A formatted character string containing up to the first N unique values from `x`, separated by " ;; ". If `x` is numeric, values are rounded to three decimal places. If `x` contains factors or dates, they are converted to character strings.