group_mean | R Documentation |

Computes the group means of a variable by a specified cluster/group. Can also be used with factors that have two levels.

```
group_mean(x, grp, lm = FALSE)
```

`x` |
Variable to compute the mean for (e.g., |

`grp` |
Cluster/grouping variable (e.g., |

`lm` |
Compute reliability (lambda) adjusted means. |

Outputs a vector of group means.

```
data(mtcars)
#create a group mean aggregated variable
mtcars$mpg.barj <- group_mean(mtcars$mpg, mtcars$cyl)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.