# avg {#avg}

## Syntax {#syntax}

`avg(X)`

## Arguments {#arguments}

**X** is a scalar/pair/vector/matrix/table.

## Details {#details}

Calculate the average of *X*.

-   If *X* is a vector, calculate the average of *X*.
-   If *X* is a matrix, calculate the average of each column and return a vector.
-   If *X* is a table, calculate the average of each column and return a table.

The calculation skips null values.

## Examples {#examples}

```
avg(1 2 3 NULL)
// output: 2

m=matrix(1 2 3, 4 5 6)
m
```

|0|1|
|---|---|
|1|4|
|2|5|
|3|6|

```
avg(m)
// output: [2,5]
```

