Get Summary of Results produced by Functions in R Programming – summary() Function

summary() function in R Language is a generic function used to produce result summaries of the results of various model fitting functions.

Syntax: summary(object, maxsum)

Parameters:
object: R object
maxsum: integer value which indicates how many levels should be shown for factors

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# summary function
  
# Initializing a character and
# integer vector
x <- c("GFG", "gfg", "Geek", "Geeks")
y <- c(1, 2, 3, 4)
  
# Calling summary() function
summary(x)
summary(y)

chevron_right


Output:

Length     Class      Mode 
4 character character 

Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
1.00    1.75    2.50    2.50    3.25    4.00 

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# summary function
  
# Initializing a data set
state.region
  
# Calling summary() function to 
# get the factor for above data set
  
# Getting all the possible levels
summary(state.region)
  
# Getting maximum 3 levels
summary(state.region, maxsum = 3)

chevron_right


Output:

 [1] South         West          West          South         West         
 [6] West          Northeast     South         South         South        
[11] West          West          North Central North Central North Central
[16] North Central South         South         Northeast     South        
[21] Northeast     North Central North Central South         North Central
[26] West          North Central West          Northeast     Northeast    
[31] West          Northeast     South         North Central North Central
[36] South         West          Northeast     Northeast     South        
[41] North Central South         South         West          Northeast    
[46] South         West          South         North Central West         
Levels: Northeast South North Central West
Northeast         South North Central          West 
     9            16            12            13 
South    West (Other) 
  16      13      21 
My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.