To calculate minkowski distance in R, you can use **dist()** function along with **method** argument.
Minkowski distance is a generalized metric that includes Euclidean distance (p = 2) and Manhattan distance (p = 1) as special cases.

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

**Method: Use dist() Function**

```
dist(matrix, method="minkowski", p)
```

The following example shows how to use **dist()** function in R.

## Use dist() Function to Calculate Minkowski Distance

Let’s see how we can calculate minkowski distance between matrices using **dist()** function.

```
# Declare vector
x <- c(7,8,9,4)
y <- c(5,8,9,7)
z <- c(5,7,1,2)
# Combine vector to create matrix
mat <- rbind(x,y,z)
# Calculate Minkowski distance
d <- dist(mat, method="minkowski", p=3)
# Show distance
print(d)
```

Output:

```
x y
y 3.271066
z 8.087579 8.608753
```

Here the output shows minkowski distance for matrices using **dist()** function.