Import your data

data("mtcars")
mtcars <- as_tibble(mtcars)
Data3 <- read_excel("../00_data/Data3.xlsx")
## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

## Warning in read_fun(path = path, sheet_i = sheet, limits = limits, shim = shim,
## : NA inserted for an unsupported date prior to 1900

Repeat the same operation over different columns of a data frame

Case of numeric variables

mtcars %>% map_dbl(.x = ., .f = ~mean(x = .x))
##        mpg        cyl       disp         hp       drat         wt       qsec 
##  20.090625   6.187500 230.721875 146.687500   3.596563   3.217250  17.848750 
##         vs         am       gear       carb 
##   0.437500   0.406250   3.687500   2.812500
mtcars %>% map_dbl( .f = ~mean(x = .x))
##        mpg        cyl       disp         hp       drat         wt       qsec 
##  20.090625   6.187500 230.721875 146.687500   3.596563   3.217250  17.848750 
##         vs         am       gear       carb 
##   0.437500   0.406250   3.687500   2.812500
mtcars %>% map_dbl(.f = mean)
##        mpg        cyl       disp         hp       drat         wt       qsec 
##  20.090625   6.187500 230.721875 146.687500   3.596563   3.217250  17.848750 
##         vs         am       gear       carb 
##   0.437500   0.406250   3.687500   2.812500
# Adding an argument
mtcars %>% map_dbl(.x = ., .f = ~mean(x = .x, trim = 0.1))
##         mpg         cyl        disp          hp        drat          wt 
##  19.6961538   6.2307692 222.5230769 141.1923077   3.5792308   3.1526923 
##        qsec          vs          am        gear        carb 
##  17.8276923   0.4230769   0.3846154   3.6153846   2.6538462
mtcars %>% map_dbl(mean, trim = 0.1)
##         mpg         cyl        disp          hp        drat          wt 
##  19.6961538   6.2307692 222.5230769 141.1923077   3.5792308   3.1526923 
##        qsec          vs          am        gear        carb 
##  17.8276923   0.4230769   0.3846154   3.6153846   2.6538462
mtcars %>% select(.data = ., mpg)
## # A tibble: 32 × 1
##      mpg
##    <dbl>
##  1  21  
##  2  21  
##  3  22.8
##  4  21.4
##  5  18.7
##  6  18.1
##  7  14.3
##  8  24.4
##  9  22.8
## 10  19.2
## # ℹ 22 more rows

Create your own function

my_vector <- c(5, 10, 15, 20, 25, 30, 35, 40, 45, 50)

# Triple Values
Triple_by_factor <- function(x, factor) {x * factor}
15 %>% Triple_by_factor(factor = 3)
## [1] 45
my_vector %>% map(.x = ., .f = ~Triple_by_factor(x = .x, factor = 3))
## [[1]]
## [1] 15
## 
## [[2]]
## [1] 30
## 
## [[3]]
## [1] 45
## 
## [[4]]
## [1] 60
## 
## [[5]]
## [1] 75
## 
## [[6]]
## [1] 90
## 
## [[7]]
## [1] 105
## 
## [[8]]
## [1] 120
## 
## [[9]]
## [1] 135
## 
## [[10]]
## [1] 150

Repeat the same operation over different elements of a list

When you have a grouping variable (factor)

mtcars %>% lm(formula = mpg ~ wt)
## 
## Call:
## lm(formula = mpg ~ wt, data = .)
## 
## Coefficients:
## (Intercept)           wt  
##      37.285       -5.344
mtcars %>% distinct(cyl)
## # A tibble: 3 × 1
##     cyl
##   <dbl>
## 1     6
## 2     4
## 3     8
reg_coeff_tbl <- mtcars %>%
    
    # Split into list of data frames
    split(.$cyl) %>% 
    
    # Repeat regression over each group
    map(.x = ., .f = ~lm(formula = mpg ~ wt, data = .x)) %>%
    
    # Extract coefficients from regression results
    
    map(broom::tidy, conf.int = TRUE) %>%
    # Convert to tibble
    
    bind_rows(.id = "cyl") %>%
    
    #Filter for wt coefficents
    filter(term == "wt")
reg_coeff_tbl %>%
    
    mutate(estimate = -estimate, conf.low = -conf.low, conf.high - -conf.high) %>%
    
    ggplot(aes(x = -estimate, y = cyl)) +
    geom_point() +
    geom_errorbar(aes(xmin = conf.low, xmax = conf.high))

Create your own

Choose either one of the two cases above and apply it to your data

Data3 %>% lm(formula = birth_month ~ birth_year)
## 
## Call:
## lm(formula = birth_month ~ birth_year, data = .)
## 
## Coefficients:
## (Intercept)   birth_year  
##   24.515093    -0.009429
Data3 %>% distinct(birth_state_province)
## # A tibble: 56 × 1
##    birth_state_province
##    <chr>               
##  1 Ontario             
##  2 Quebec              
##  3 NA                  
##  4 Massachusetts       
##  5 Wisconsin           
##  6 Minnesota           
##  7 Michigan            
##  8 North Dakota        
##  9 Manitoba            
## 10 Saskatchewan        
## # ℹ 46 more rows
reg_coeff_tbl2 <- Data3 %>% 
    split(.$birth_state_province) %>%
    map(.x = ., .f = ~lm(formula = birth_month ~ birth_year, data = .x)) %>%
    map(broom::tidy, confint = TRUE) %>%  
    bind_rows(.id = "birth_month")
reg_coeff_tbl2 %>%
    ggplot(aes(x = -estimate, y = birth_month)) +
    geom_point() 
## Warning: Removed 7 rows containing missing values (`geom_point()`).