R Program to get the statistical summary and nature of the data of a given data frame


August 25, 2021, Learn eTutorial
838

How to get the statistical summary and nature of the data of a given data frame

Here we are explaining how to write an R program to get the statistical summary and nature of the data of a given data frame. Here we are using built-in function data.frame(),summary() for this. A data frame is used for storing data tables which has a list of vectors with equal length. The data frames are created by function data.frame(), which has tightly coupled collections of variables. And the function summary() is helps to produce result summaries of the results of various model fitting functions. The syntax of this function is, 


summary(object, …) 

Where dots(...) additional arguments affecting the summary produced and object is an object for which a summary is desired.

How to get the statistical summary and nature of the data of a given data frame in the R program

Below are the steps used in the R program to get the statistical summary and nature of the data of a given data frame. In this R program, we directly give the data frame to a built-in function. Here we are using variables E, N, S, A, Q for holding different types of vectors. Call the function data.frame() for creating dataframe. Finally, the statistical summary is calculated from a given data frame by calling like summary(E)

ALGORITHM

STEP 1: Assign variables E,N,S,A,Q with vector values 

STEP 2: First print original vector values

STEP 3: Print the statistical summary of a given data frame as summary(E)

STEP 4: Print the final data frame

R Source Code

                                          E = data.frame(
N = c('Jhon', 'Hialy', 'Albert', 'James', 'Delma'),
S = c(10, 9.5, 12.2, 11, 8),
A = c(2, 1, 2, 4, 1),
Q = c('yes', 'no', 'yes', 'no', 'no')
)
print("Original dataframe:")
print(E)
print("Statistical summary and nature of the data of the dataframe:")
print(summary(E))
                                      

OUTPUT

[1] "Original dataframe:"
     name    score attempts qualify
1  Jhon       10        2     yes
2  Hialy      9.5       1     no
3  Albert     12.2      2     yes
4  James      11        4     no
5  Delma      8         1     no

[1] "Statistical summary and nature of the data of the dataframe:"
      N           S               A       Q    
 Albert:1   Min.   : 8.00   Min.   :1   no :3  
 Delma :1   1st Qu.: 9.50   1st Qu.:1   yes:2  
 Hialy :1   Median :10.00   Median :2          
 James :1   Mean   :10.14   Mean   :2          
 Jhon  :1   3rd Qu.:11.00   3rd Qu.:2          
            Max.   :12.20   Max.   :4