glimpse Function in R


When exploring your data, doing exploratory data analysis (EDA), the glimpse function is very handy. glimpse() is part of the dplyr package in R. If you get an error saying it can’t find glimpse, you need to run library(‘dplyr’) to load the library before you run glimpse.

As an example, we are looking at the Palmer Penguins data.

> glimpse(penguins)
Rows: 344
Columns: 8
$ species           <fct> Adelie, Adelie, Adelie, Adelie, Adelie, Adelie, …
$ island            <fct> Torgersen, Torgersen, Torgersen, Torgersen, Torg…
$ bill_length_mm    <dbl> 39.1, 39.5, 40.3, NA, 36.7, 39.3, 38.9, 39.2, 34…
$ bill_depth_mm     <dbl> 18.7, 17.4, 18.0, NA, 19.3, 20.6, 17.8, 19.6, 18…
$ flipper_length_mm <int> 181, 186, 195, NA, 193, 190, 181, 195, 193, 190,…
$ body_mass_g       <int> 3750, 3800, 3250, NA, 3450, 3650, 3625, 4675, 34…
$ sex               <fct> male, female, female, NA, female, male, female, …
$ year              <int> 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, …

fct means a factor variable, also known as a categorical variable. dbl stands for double class. A double-precision floating point number. int means a quantitative variable that takes only integer or whole number values.

A categorical variable (also called qualitative variable) refers to a characteristic that can’t be quantifiable. Categorical variables can be either nominal or ordinal.

Leave a Reply