R allows for installation and use of toolboxes (called packages) made by third parties. Such packages are often useful for specific types of analyses and provide multitudes of functions and possibilities. With regards to descriptive statistics, the package **pastecs** is one of these toolboxes. Note that such a package must be installed/activated in R prior to analyzing data. NB: if pastecs is not installed yet, simply use the following code:

install.packages("pastecs")
## Installing package into 'C:/Program Files/R/library'
## (as 'lib' is unspecified)
## package 'pastecs' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\femjs\AppData\Local\Temp\Rtmp6VY48c\downloaded_packages

Once the package has been installed, you will need to activate it everytime you restart R/Rstudio. Use this line of code:

library(pastecs)


Pastecs contains a multitude of functions, among which stat.desc(). Running stat.desc() on a dataset returns a list of useful parameters such as number of values, number of null values, number of missing values, minimum, maximum, range, median, mean, standard error of the mean, standard deviation, variance and more. Let’s use stat.desc() on the following example:

my.dataset <- c(1,2,3,4,5,6,7,8,9,10)
stat.desc(my.dataset)
##      nbr.val     nbr.null       nbr.na          min          max 
##   10.0000000    0.0000000    0.0000000    1.0000000   10.0000000 
##        range          sum       median         mean      SE.mean 
##    9.0000000   55.0000000    5.5000000    5.5000000    0.9574271 
## CI.mean.0.95          var      std.dev     coef.var 
##    2.1658506    9.1666667    3.0276504    0.5504819

stat.desc() is one of many functions included in pastecs. You may find more info and learn about all the possibilities given by the package by clicking here.

Sadly, stat.desc() displays values using a scientific notation which does not look so attractive to the reader. It is possible to use the command options() to simplify the display. Note that you have to use the command options() prior to running stat.desc():

options(scipen=100)
options(digits=2)
my.dataset <- c(1,2,3,4,5,6,7,8,9,10)
stat.desc(my.dataset)
##      nbr.val     nbr.null       nbr.na          min          max 
##        10.00         0.00         0.00         1.00        10.00 
##        range          sum       median         mean      SE.mean 
##         9.00        55.00         5.50         5.50         0.96 
## CI.mean.0.95          var      std.dev     coef.var 
##         2.17         9.17         3.03         0.55