The **min()** and **max()** function is used to find minimum and maximum values from list, data frame or vector in R.

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

**Method: Use min() and max() Function**

```
min(x)
max(x)
```

The following examples shows how to use **min()** and **max()** in R.

## Use min() and max() Function on Vector

Let’s see how we can find minimum and maximum value from numeric vector:

```
# Create dataset
data <- c(78,89,85,84,81,79,77,85,85,81,78,89,84,84,81,80)
# Find maximum value
max_value <- max(data)
# Find minumum value
min_value <- min(data)
# Show maximum value
print(max_value)
# Show minimum value
print(min_value)
```

Output:

```
[1] 89
[1] 77
```

As we can see the **min()** function return 77 as minimum value and **max()** function return 89 as maximum value from vector.

## Use min() and max() Function on Data Frame

We can find the maximum and minimum value from entire data frame:

```
# Create data frame
df <- data.frame(Pressure=c(12.39,11.25,12.15,13.48,13.78,12.89,12.21,12.58),
Temperature=c(78,89,85,84,81,79,77,85),
Humidity=c(5,7,1,2,7,8,9,4))
# Find maximum value from data frame
max_value <- max(df)
# Find minumum value from data frame
min_value <- min(df)
# Show maximum value
print(max_value)
# Show minimum value
print(min_value)
```

Output:

```
[1] 89
[1] 1
```

Here we get 89 as maximum value and 1 as minimum value from entire data frame.