Learn R Programming

describer

describer quickly and easily describes data using common descriptive statistics.

Installation

You can install:

  • the latest released version from CRAN:

    install.packages("describer")
  • the latest development version from Github:

    if (packageVersion("devtools") < 1.6) {
      install.packages("devtools")
    }
    devtools::install_github("paulhendricks/describer")

If you encounter a clear bug, please file a minimal reproducible example on github.

API

library(dplyr, warn.conflicts = FALSE)
library(describer)

mtcars %>% 
  describe %>% 
  knitr::kable(format = "markdown")
.column_name.column_class.column_type.count_elements.mean_value.sd_value.q0_value.q25_value.q50_value.q75_value.q100_value
mpgnumericdouble3220.0906256.026948110.40015.4250019.20022.8033.900
cylnumericdouble326.1875001.78592164.0004.000006.0008.008.000
dispnumericdouble32230.721875123.938693871.100120.82500196.300326.00472.000
hpnumericdouble32146.68750068.562868552.00096.50000123.000180.00335.000
dratnumericdouble323.5965630.53467872.7603.080003.6953.924.930
wtnumericdouble323.2172500.97845741.5132.581253.3253.615.424
qsecnumericdouble3217.8487501.786943214.50016.8925017.71018.9022.900
vsnumericdouble320.4375000.50401610.0000.000000.0001.001.000
amnumericdouble320.4062500.49899090.0000.000000.0001.001.000
gearnumericdouble323.6875000.73780413.0003.000004.0004.005.000
carbnumericdouble322.8125001.61520001.0002.000002.0004.008.000

mtcars %>% 
  group_by(cyl) %>% 
  do(describe(.)) %>% 
  knitr::kable(format = "markdown")
cyl.column_name.column_class.column_type.count_elements.mean_value.sd_value.q0_value.q25_value.q50_value.q75_value.q100_value
4mpgnumericdouble1126.66363644.509827721.40022.800026.00030.4000033.900
4cylnumericdouble114.00000000.00000004.0004.00004.0004.000004.000
4dispnumericdouble11105.136363626.871593771.10078.8500108.000120.65000146.700
4hpnumericdouble1182.636363620.934530052.00065.500091.00096.00000113.000
4dratnumericdouble114.07090910.36547113.6903.81004.0804.165004.930
4wtnumericdouble112.28572730.56956371.5131.88502.2002.622503.190
4qsecnumericdouble1119.13727271.682445216.70018.560018.90019.9500022.900
4vsnumericdouble110.90909090.30151130.0001.00001.0001.000001.000
4amnumericdouble110.72727270.46709940.0000.50001.0001.000001.000
4gearnumericdouble114.09090910.53935993.0004.00004.0004.000005.000
4carbnumericdouble111.54545450.52223301.0001.00002.0002.000002.000
6mpgnumericdouble719.74285711.453567017.80018.650019.70021.0000021.400
6cylnumericdouble76.00000000.00000006.0006.00006.0006.000006.000
6dispnumericdouble7183.314285741.5624602145.000160.0000167.600196.30000258.000
6hpnumericdouble7122.285714324.2604911105.000110.0000110.000123.00000175.000
6dratnumericdouble73.58571430.47605522.7603.35003.9003.910003.920
6wtnumericdouble73.11714290.35634552.6202.82253.2153.440003.460
6qsecnumericdouble717.97714291.706865715.50016.740018.30019.1700020.220
6vsnumericdouble70.57142860.53452250.0000.00001.0001.000001.000
6amnumericdouble70.42857140.53452250.0000.00000.0001.000001.000
6gearnumericdouble73.85714290.69006563.0003.50004.0004.000005.000
6carbnumericdouble73.42857141.81265391.0002.50004.0004.000006.000
8mpgnumericdouble1415.10000002.560048110.40014.400015.20016.2500019.200
8cylnumericdouble148.00000000.00000008.0008.00008.0008.000008.000
8dispnumericdouble14353.100000067.7713236275.800301.7500350.500390.00000472.000
8hpnumericdouble14209.214285750.9768855150.000176.2500192.500241.25000335.000
8dratnumericdouble143.22928570.37236182.7603.07003.1153.225004.220
8wtnumericdouble143.99921430.75940473.1703.53253.7554.013755.424
8qsecnumericdouble1416.77214291.196013814.50016.097517.17517.5550018.000
8vsnumericdouble140.00000000.00000000.0000.00000.0000.000000.000
8amnumericdouble140.14285710.36313650.0000.00000.0000.000001.000
8gearnumericdouble143.28571430.72627303.0003.00003.0003.000005.000
8carbnumericdouble143.50000001.55662362.0002.25003.5004.000008.000

To mimic the exact pandas.describe() behavior, use reshape2 to melt() and cast() the data into an appropriate form. This is not recommendated as all columns will be coerced into character vectors.

library(reshape2)

pandas_describe_mtcars <- 
  mtcars %>% 
  describe %>% 
  melt(id.vars = ".column_name", variable.name = ".variable") %>% 
  dcast(.variable ~ .column_name, value.var = "value")

pandas_describe_mtcars %>% 
  knitr::kable(format = "markdown")
.variableamcarbcyldispdratgearhpmpgqsecvswt
.column_classnumericnumericnumericnumericnumericnumericnumericnumericnumericnumericnumeric
.column_typedoubledoubledoubledoubledoubledoubledoubledoubledoubledoubledouble
.count_elements3232323232323232323232
.mean_value0.406252.81256.1875230.7218753.59656253.6875146.687520.09062517.848750.43753.21725
.sd_value0.4989909172358461.615199977631851.78592164694654123.9386938313820.5346787360709710.73780406525694768.56286848932066.02694805208911.786943236096840.5040161287741850.978457442989697
.q0_value01471.12.7635210.414.501.513
.q25_value024120.8253.08396.515.42516.892502.58125
.q50_value026196.33.695412319.217.7103.325
.q75_value1483263.92418022.818.913.61
.q100_value1884724.93533533.922.915.424

str(pandas_describe_mtcars)
#> 'data.frame':    10 obs. of  12 variables:
#>  $ .variable: Factor w/ 10 levels ".column_class",..: 1 2 3 4 5 6 7 8 9 10
#>  $ am       : chr  "numeric" "double" "32" "0.40625" ...
#>  $ carb     : chr  "numeric" "double" "32" "2.8125" ...
#>  $ cyl      : chr  "numeric" "double" "32" "6.1875" ...
#>  $ disp     : chr  "numeric" "double" "32" "230.721875" ...
#>  $ drat     : chr  "numeric" "double" "32" "3.5965625" ...
#>  $ gear     : chr  "numeric" "double" "32" "3.6875" ...
#>  $ hp       : chr  "numeric" "double" "32" "146.6875" ...
#>  $ mpg      : chr  "numeric" "double" "32" "20.090625" ...
#>  $ qsec     : chr  "numeric" "double" "32" "17.84875" ...
#>  $ vs       : chr  "numeric" "double" "32" "0.4375" ...
#>  $ wt       : chr  "numeric" "double" "32" "3.21725" ...

People

License

Copy Link

Version

Install

install.packages('describer')

Monthly Downloads

365

Version

0.2.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

September 17th, 2015

Functions in describer (0.2.0)

describe_numeric

Describe numeric atomic vectors.
describer

describer: Describe Data in R Using Common Descriptive Statistics
describe_nonnumeric

Describe non-numeric atomic vectors.
describe

Describe atomic vectors or data.frames.