R Identify Unique Values in List Object (Example Code)
This article illustrates how to return all unique list values in R.
Creation of Example Data
example_list <- list(9:4, # Example list in R 12:3, 10:7, 20:19, 1:7, 15) example_list # [[1]] # [1] 9 8 7 6 5 4 # # [[2]] # [1] 12 11 10 9 8 7 6 5 4 3 # # [[3]] # [1] 10 9 8 7 # # [[4]] # [1] 20 19 # # [[5]] # [1] 1 2 3 4 5 6 7 # # [[6]] # [1] 15 # |
example_list <- list(9:4, # Example list in R 12:3, 10:7, 20:19, 1:7, 15) example_list # [[1]] # [1] 9 8 7 6 5 4 # # [[2]] # [1] 12 11 10 9 8 7 6 5 4 3 # # [[3]] # [1] 10 9 8 7 # # [[4]] # [1] 20 19 # # [[5]] # [1] 1 2 3 4 5 6 7 # # [[6]] # [1] 15 #
Example: Returning Unique List Values in R
unique(unlist(example_list)) # Finding unique elements # [1] 9 8 7 6 5 4 12 11 10 3 20 19 1 2 15 |
unique(unlist(example_list)) # Finding unique elements # [1] 9 8 7 6 5 4 12 11 10 3 20 19 1 2 15
Further Resources & Related Tutorials
You may have a look at the following R tutorials. They focus on topics such as data inspection, missing data, lists, and variables.