summary()
   get_help() docs


Description

The summary() function comes with R and is part of the Base R {base} package.

We use this function to generally summarize objects and variables. Most commonly, we summarize objects like tibbles/data frames, arrays, and statistical model output.

Conceptual Usage

summary(object to summarize)

Examples

The examples below use the msleep dataset. Learn more about this dataset with get_help("msleep").

# Show the msleep dataset with head()
head(msleep)
## # A tibble: 6 × 11
##   name  genus vore  order conservation sleep_total sleep_rem sleep_cycle awake  brainwt  bodywt
##   <chr> <chr> <chr> <chr> <chr>              <dbl>     <dbl>       <dbl> <dbl>    <dbl>   <dbl>
## 1 Owl … Aotus omni  Prim… <NA>                17         1.8      NA       7    0.0155    0.48 
## 2 Moun… Aplo… herbi Rode… nt                  14.4       2.4      NA       9.6 NA         1.35 
## 3 Grea… Blar… omni  Sori… lc                  14.9       2.3       0.133   9.1  0.00029   0.019
## 4 Cow   Bos   herbi Arti… domesticated         4         0.7       0.667  20    0.423   600    
## 5 Thre… Brad… herbi Pilo… <NA>                14.4       2.2       0.767   9.6 NA         3.85 
## 6 Nort… Call… carni Carn… vu                   8.7       1.4       0.383  15.3 NA        20.5


# Summarize the msleep tibble to get information about all columns
summary(msleep)
##      name              genus               vore              order          
##  Length:61          Length:61          Length:61          Length:61         
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##  conservation        sleep_total      sleep_rem      sleep_cycle         awake      
##  Length:61          Min.   : 1.90   Min.   :0.100   Min.   :0.1167   Min.   : 4.10  
##  Class :character   1st Qu.: 8.00   1st Qu.:0.900   1st Qu.:0.1833   1st Qu.:10.30  
##  Mode  :character   Median :10.00   Median :1.500   Median :0.3333   Median :14.00  
##                     Mean   :10.39   Mean   :1.875   Mean   :0.4396   Mean   :13.61  
##                     3rd Qu.:13.70   3rd Qu.:2.400   3rd Qu.:0.5792   3rd Qu.:16.00  
##                     Max.   :19.90   Max.   :6.600   Max.   :1.5000   Max.   :22.10  
##                                                     NA's   :29                      
##     brainwt             bodywt       
##  Min.   :0.000140   Min.   :  0.005  
##  1st Qu.:0.002475   1st Qu.:  0.205  
##  Median :0.011750   Median :  1.670  
##  Mean   :0.106472   Mean   : 63.295  
##  3rd Qu.:0.115000   3rd Qu.: 20.490  
##  Max.   :1.320000   Max.   :899.995  
##  NA's   :13


# Summarize an array
summary(msleep$awake)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    4.10   10.30   14.00   13.61   16.00   22.10


# Summarize a linear model
fit <- lm(awake ~ bodywt, data = msleep)
summary(fit)
## 
## Call:
## lm(formula = awake ~ bodywt, data = msleep)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -8.6852 -2.5062  0.9142  2.3136  6.6896 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 12.785060   0.530457  24.102  < 2e-16 ***
## bodywt       0.013069   0.002795   4.676 1.75e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.906 on 59 degrees of freedom
## Multiple R-squared:  0.2704, Adjusted R-squared:  0.258 
## F-statistic: 21.87 on 1 and 59 DF,  p-value: 1.746e-05