Descriptive or summary statistics in R

Summary Statistics of the dataframe in R can be calculated by 3 different methods. Let’s see how to calculate descriptive statistics in R with an example for each method.

Let’s first create the dataframe.

### Create Data Frame
df1 = data.frame(Name = c('George','Andrea', 'Micheal','Maggie','Ravi','Xien','Jalpa'), 
                 Grade_score=c(4,6,2,9,5,7,8),
                 Mathematics1_score=c(45,78,44,89,66,49,72),
                 Science_score=c(56,52,45,88,33,90,47))
df1

So the resultant dataframe will be

Descriptive or summary statistics in R 0

 

Descriptive or summary statistics in R (Method 1):

Descriptive statistics in R with simple summary function

# Summary statistics of dataframe in R

summary(df1)

summary statistics is

Descriptive or summary statistics in R 1

 

Descriptive or summary statistics in R (Method 2):

Descriptive statistics in R with pastecs package

# descripive statistics of dataframe in R 

install.packages("pastecs")  
library(pastecs)
stat.desc(df1)

summary statistics is

Descriptive or summary statistics in R 2

 

Descriptive or summary statistics in R (Method 3):

Descriptive statistics in R with Hmisc package

# Summary statistics of dataframe in R 

install.packages("Hmisc")
library(Hmisc)
describe(df1)

summary statistics is

Descriptive or summary statistics in R 3

 

Descriptive or summary statistics in R - image previous-small-11-1 on http://www.datasciencemadesimple.com                                                                                                         Descriptive or summary statistics in R - image next_small-11-1 on http://www.datasciencemadesimple.com