dmkillo.blogg.se

Stata mean by group
Stata mean by group





stata mean by group

We first have to install and load the purrr package: This example relies on the functions of the purrr package (another add-on package provided by the tidyverse).

stata mean by group

In Example 3, I’ll illustrate another alternative for the calculation of summary statistics by group in R. Whether you prefer to use the basic installation or the dplyr package is a matter of taste.Įxample 3: Descriptive Summary Statistics by Group Using purrr Package The output of the previous R code is a tibble that contains basically the same values as the list created in Example 1. Each of these list elements contains basic summary statistics for the corresponding group.Įxample 2: Descriptive Summary Statistics by Group Using dplyr PackageĪnother alternative for the computation of descriptive summary statistics is provided by the dplyr package.įirst, we have to install and load the dplyr package: The output of the previous R syntax is a list containing one list element for each group.

stata mean by group

Tapply(data$x, data$group, summary) # Summary by group using tapply Tapply (data$x, data$group, summary ) # Summary by group using tapply # $A # Min.







Stata mean by group