Prepare data and make default table

There are many ways to make a concise descriptive statistics table. One option is shown below.

Prepare data:

mtcars.partial <- mtcars[c("mpg","cyl","am","hp")]

Default descriptive statistics table from the pastecs package:

if(!require(pastecs)) install.packages("pastecs")
library(pastecs)

descriptivetable <- stat.desc(mtcars.partial)

descriptivetable
##                      mpg         cyl          am           hp
## nbr.val       32.0000000  32.0000000 32.00000000   32.0000000
## nbr.null       0.0000000   0.0000000 19.00000000    0.0000000
## nbr.na         0.0000000   0.0000000  0.00000000    0.0000000
## min           10.4000000   4.0000000  0.00000000   52.0000000
## max           33.9000000   8.0000000  1.00000000  335.0000000
## range         23.5000000   4.0000000  1.00000000  283.0000000
## sum          642.9000000 198.0000000 13.00000000 4694.0000000
## median        19.2000000   6.0000000  0.00000000  123.0000000
## mean          20.0906250   6.1875000  0.40625000  146.6875000
## SE.mean        1.0654240   0.3157093  0.08820997   12.1203173
## CI.mean.0.95   2.1729465   0.6438934  0.17990541   24.7195501
## var           36.3241028   3.1895161  0.24899194 4700.8669355
## std.dev        6.0269481   1.7859216  0.49899092   68.5628685
## coef.var       0.2999881   0.2886338  1.22828533    0.4674077

The table above might be all you need. If you want to further customize the table, keep reading below.

Customize table

Transpose the table:

descriptivetable.transpose <- as.data.frame(t(as.matrix(descriptivetable)))

descriptivetable.transpose
##     nbr.val nbr.null nbr.na  min   max range    sum median      mean
## mpg      32        0      0 10.4  33.9  23.5  642.9   19.2  20.09062
## cyl      32        0      0  4.0   8.0   4.0  198.0    6.0   6.18750
## am       32       19      0  0.0   1.0   1.0   13.0    0.0   0.40625
## hp       32        0      0 52.0 335.0 283.0 4694.0  123.0 146.68750
##         SE.mean CI.mean.0.95          var    std.dev  coef.var
## mpg  1.06542396    2.1729465   36.3241028  6.0269481 0.2999881
## cyl  0.31570933    0.6438934    3.1895161  1.7859216 0.2886338
## am   0.08820997    0.1799054    0.2489919  0.4989909 1.2282853
## hp  12.12031731   24.7195501 4700.8669355 68.5628685 0.4674077

Select and re-order specific items from the transposed table and only display those, also rounding certain statistics:

descriptivetable.abbreviated <- data.frame(N = descriptivetable.transpose$nbr.val, Mean = round(descriptivetable.transpose$mean,1), SD = round(descriptivetable.transpose$std.dev,1), Missing = descriptivetable.transpose$nbr.na)

row.names(descriptivetable.abbreviated) <- row.names(descriptivetable.transpose)

descriptivetable.abbreviated
##      N  Mean   SD Missing
## mpg 32  20.1  6.0       0
## cyl 32   6.2  1.8       0
## am  32   0.4  0.5       0
## hp  32 146.7 68.6       0

Improve aesthetics

Make it look nicer if you are using R Markdown:

library(knitr)
knitr::kable(descriptivetable.abbreviated)
N Mean SD Missing
mpg 32 20.1 6.0 0
cyl 32 6.2 1.8 0
am 32 0.4 0.5 0
hp 32 146.7 68.6 0

Make it look even nicer in R Markdown:

if (!require(DT)) install.packages('DT') 
library(DT)

DT::datatable(descriptivetable.abbreviated)

Additional information

Click here for more possibly-useful code