9. Pastecs


R allows 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/loaded in R prior to analyzing data. NB: if pastecs is not installed yet and you don’t know how to install a package, this video will help you.

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)

Skjermbilde 2016-06-01 23.14.03

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

Sadly, stat.desc() displays values using a scientific notation which makes the reader feel rather dizzy, not necessarily satisfied. Fortunately, R and pastecs are “customizable” to some extent, and it is possible to use the command options() to make things look slightly better. The values remain the same, their display becomes simpler and your degree of happiness increases. 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)

Skjermbilde 2016-06-01 23.26.47