**Introduction**

Often, there are only two considerations for summary statistics in basic statistical analysis: Providing means and standard deviations; and creating good-looking tables. In this blog, we’ll show you how to use the Stargazer package in Stata to achieve both of these goals with 5 summary statistics: N, mean, standard deviation, minimum value, and maximum value.

Note that, in another blog entry, we’ve discussed the use of Stargazer for reporting regression results.

**Load the Stargazer Package**

You can load the Stargazer package in R as follows:

install.packages("stargazer")

**Access the Dataset**

Let’s work with the attitude dataset that comes prebuilt in R. You can get a look at its first 10 values here:

head(attitude, n=10)

**Get Your Summary Statistics: Text Version**

Let’s say you want to generate a table in the R Studio console that you can copy and paste. You can use the following code, which tells Stargazer that you want text type:

library(stargazer)

stargazer(attitude, type = "text")

Here’s what you get:

Let’s say, though, that you want to capitalize the variable names, but without the hassle of renaming the variables in R itself. Stargazer lets you use the covariate.labels function to do that. Try the following:

stargazer(attitude, type = "text",

covariate.labels=c("Rating","Complaints","Privileges","Learning",

"Raises","Critical","Advance"))

Here’s what you get:

**Get Your Summary Statistics: Latex Version**

Let’s say you want to generate the same table in Latex. You like the option that let you capitalize the variable names, so you keep that part of the code. Leave out the text option for the Latex output:

stargazer(attitude,

covariate.labels=c("Rating","Complaints","Privileges","Learning",

"Raises","Critical","Advance"))

Here’s what the Latex output looks like in R:

You can now insert this code into a Latex editor to get a Latex version of the table. We pasted this code into Overleaf to generate the following table:

**Conclusion**

R has several ways of generating summary statistics. Stargazer has the advantage of generating aesthetic tables, both in text and Latex formats, but, if you require other summary statistics, Stargazer might not be the right approach.

BridgeText can help you with all of your **statistical analysis needs**.