Original de Oscar Torres-Reyna
mydata <- mtcars
if (!require("stargazer")) {
install.packages("stargazer", repos="http://cran.rstudio.com/")
library("stargazer")
}
## Loading required package: stargazer
##
## Please cite as:
## Hlavac, Marek (2015). stargazer: Well-Formatted Regression and Summary Statistics Tables.
## R package version 5.2. http://CRAN.R-project.org/package=stargazer
stargazer(mydata, type = "text", title = "Descriptive statistics", digits = 1, out = "table1.txt")
##
## Descriptive statistics
## ======================================
## Statistic N Mean St. Dev. Min Max
## --------------------------------------
## mpg 32 20.1 6.0 10.4 33.9
## cyl 32 6.2 1.8 4 8
## disp 32 230.7 123.9 71.1 472.0
## hp 32 146.7 68.6 52 335
## drat 32 3.6 0.5 2.8 4.9
## wt 32 3.2 1.0 1.5 5.4
## qsec 32 17.8 1.8 14.5 22.9
## vs 32 0.4 0.5 0 1
## am 32 0.4 0.5 0 1
## gear 32 3.7 0.7 3 5
## carb 32 2.8 1.6 1 8
## --------------------------------------
You can also embed plots, for example:
##
## Descriptive statistics
## ==============================================================
## Statistic mpg cyl disp hp drat wt qsec vs am gear carb
## --------------------------------------------------------------
## N 32 32 32 32 32 32 32 32 32 32 32
## Mean 20.1 6.2 230.7 146.7 3.6 3.2 17.8 0.4 0.4 3.7 2.8
## St. Dev. 6.0 1.8 123.9 68.6 0.5 1.0 1.8 0.5 0.5 0.7 1.6
## Min 10.4 4 71.1 52 2.8 1.5 14.5 0 0 3 1
## Max 33.9 8 472.0 335 4.9 5.4 22.9 1 1 5 8
## --------------------------------------------------------------
Note that the echo = FALSE
parameter was added to the code chunk to prevent printing of the R code that generated the plot.