list_values | R Documentation |
Get a vector with all unique values found in a given column of a data.frame.
Concatenated values (A,B
) in the column can be returned as single values
(A
and B
).
list_values(.data, column, split = ",")
.data |
Data frame. Data.frame to select column from. |
column |
Character or integer. Quoted or unqoted column name or column position. |
split |
Character (vector). Character or regular expression(s) passed
to |
A vector of the same type as the given column.
# Set default connection variable
con <- connect_to_etn()
library(dplyr) # For %>%
# List unique scientific_name from a dataframe containing animal information
df <- get_animals(con, animal_project_code = "2014_demer")
list_values(df, "scientific_name")
# Or using pipe and unquoted column name
df %>% list_values(scientific_name)
# Or using column position
df %>% list_values(8)
# tag_serial_number can contain comma-separated values
df <- get_animals(con, animal_id = 5841)
df$tag_serial_number
# list_values() will split those and return unique values
list_values(df, tag_serial_number)
# Another expression can be defined to split values (here ".")
list_values(df, tag_serial_number, split = "\\.")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.