To find the unique values from column of dataframe, you can use unique() function.

The following method shows how you can do it with syntax.

Method 1: Use unique() Function


The following example shows how to find unique values from column of dataframe in R.

Using unique() Function

Let’s see how we can use unique() function in R:

# Create data frame
df <- data.frame(Machine_name=c("A","D","B","C","B","D","C","A"),
                 Pressure=c(78.2, 81.21, 71.7, 80.21, 71.7, 81.21, 80.21, 78.2),
                 Temperature=c(31, 33, 36, 37, 36, 33, 37, 31),

# Find unique values
u <- unique(df$Machine_name)

# Print unique values


[1] "A" "D" "B" "C"

Here the output shows unique values from Machine_name column of dataframe.