Data sets for for teaching

1 Load packages

library(tidyverse)  # data wrangling

2 Data

Here’s a opionated list of data sets useful for teaching purposes:

Note that the data sets are provided as standard CSV files (comma separeted, dots as delimiters).

3 Data repositories

Check this out for longish compilations of data sets useful for data analysis:

4 How to import into R

  1. Open the web page of the data by clicking on the respective [csv] link (above)
  2. Copy the URL of that web page to your clipboard (control-c)
  3. Paste the URL to the following R code
  4. Execute the R code below:
# replace the following URL with your URL
data_url <- "https://vincentarelbundock.github.io/Rdatasets/csv/AER/TeachingRatings.csv"

library(tidyverse)  # remember to install once upfront

d <- read_csv(data_url)

Check it:

glimpse(d)
#> Rows: 463
#> Columns: 13
#> $ ...1        <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,…
#> $ minority    <chr> "yes", "no", "no", "no", "no", "no", "no", "no", "no", "no…
#> $ age         <dbl> 36, 59, 51, 40, 31, 62, 33, 51, 33, 47, 35, 37, 42, 49, 37…
#> $ gender      <chr> "female", "male", "male", "female", "female", "male", "fem…
#> $ credits     <chr> "more", "more", "more", "more", "more", "more", "more", "m…
#> $ beauty      <dbl> 0.2899157, -0.7377322, -0.5719836, -0.6779634, 1.5097940, …
#> $ eval        <dbl> 4.3, 4.5, 3.7, 4.3, 4.4, 4.2, 4.0, 3.4, 4.5, 3.9, 3.1, 4.0…
#> $ division    <chr> "upper", "upper", "upper", "upper", "upper", "upper", "upp…
#> $ native      <chr> "yes", "yes", "yes", "yes", "yes", "yes", "yes", "yes", "y…
#> $ tenure      <chr> "yes", "yes", "yes", "yes", "yes", "yes", "yes", "yes", "y…
#> $ students    <dbl> 24, 17, 55, 40, 42, 182, 33, 25, 48, 16, 18, 30, 28, 30, 2…
#> $ allstudents <dbl> 43, 20, 55, 46, 48, 282, 41, 41, 60, 19, 25, 34, 40, 36, 2…
#> $ prof        <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,…

Yeah!

Don’t worry about the first column with the strange name ...1, that’s nothing but a technical artifact. Just ignore it.

5 Reproducibility

#> ─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.1.2 (2021-11-01)
#>  os       macOS Big Sur 10.16         
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Berlin               
#>  date     2022-02-23                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
#>  package     * version date       lib source                            
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 4.1.0)                    
#>  backports     1.4.1   2021-12-13 [1] CRAN (R 4.1.0)                    
#>  blogdown      1.8     2022-02-16 [2] CRAN (R 4.1.2)                    
#>  bookdown      0.24.2  2021-10-15 [1] Github (rstudio/bookdown@ba51c26) 
#>  brio          1.1.3   2021-11-30 [1] CRAN (R 4.1.0)                    
#>  broom         0.7.12  2022-01-28 [1] CRAN (R 4.1.2)                    
#>  bslib         0.3.1   2021-10-06 [1] CRAN (R 4.1.0)                    
#>  cachem        1.0.6   2021-08-19 [1] CRAN (R 4.1.0)                    
#>  callr         3.7.0   2021-04-20 [1] CRAN (R 4.1.0)                    
#>  cellranger    1.1.0   2016-07-27 [1] CRAN (R 4.1.0)                    
#>  cli           3.1.1   2022-01-20 [1] CRAN (R 4.1.2)                    
#>  codetools     0.2-18  2020-11-04 [2] CRAN (R 4.1.2)                    
#>  colorout    * 1.2-2   2022-01-04 [1] Github (jalvesaq/colorout@79931fd)
#>  colorspace    2.0-2   2021-06-24 [1] CRAN (R 4.1.0)                    
#>  crayon        1.4.2   2021-10-29 [1] CRAN (R 4.1.0)                    
#>  DBI           1.1.2   2021-12-20 [1] CRAN (R 4.1.0)                    
#>  dbplyr        2.1.1   2021-04-06 [1] CRAN (R 4.1.0)                    
#>  desc          1.4.0   2021-09-28 [1] CRAN (R 4.1.0)                    
#>  devtools      2.4.3   2021-11-30 [1] CRAN (R 4.1.0)                    
#>  digest        0.6.29  2021-12-01 [1] CRAN (R 4.1.0)                    
#>  dplyr       * 1.0.8   2022-02-08 [1] CRAN (R 4.1.2)                    
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.0)                    
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 4.1.0)                    
#>  fansi         1.0.2   2022-01-14 [1] CRAN (R 4.1.2)                    
#>  fastmap       1.1.0   2021-01-25 [2] CRAN (R 4.1.0)                    
#>  forcats     * 0.5.1   2021-01-27 [1] CRAN (R 4.1.0)                    
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.1.0)                    
#>  generics      0.1.2   2022-01-31 [1] CRAN (R 4.1.2)                    
#>  ggplot2     * 3.3.5   2021-06-25 [1] CRAN (R 4.1.0)                    
#>  glue          1.6.1   2022-01-22 [1] CRAN (R 4.1.2)                    
#>  gtable        0.3.0   2019-03-25 [1] CRAN (R 4.1.0)                    
#>  haven         2.4.3   2021-08-04 [1] CRAN (R 4.1.0)                    
#>  hms           1.1.1   2021-09-26 [1] CRAN (R 4.1.0)                    
#>  htmltools     0.5.2   2021-08-25 [1] CRAN (R 4.1.0)                    
#>  httr          1.4.2   2020-07-20 [1] CRAN (R 4.1.0)                    
#>  jquerylib     0.1.4   2021-04-26 [1] CRAN (R 4.1.0)                    
#>  jsonlite      1.7.3   2022-01-17 [1] CRAN (R 4.1.2)                    
#>  knitr         1.37    2021-12-16 [1] CRAN (R 4.1.0)                    
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.1.0)                    
#>  lubridate     1.8.0   2021-10-07 [1] CRAN (R 4.1.0)                    
#>  magrittr      2.0.2   2022-01-26 [1] CRAN (R 4.1.2)                    
#>  memoise       2.0.0   2021-01-26 [2] CRAN (R 4.1.0)                    
#>  modelr        0.1.8   2020-05-19 [1] CRAN (R 4.1.0)                    
#>  munsell       0.5.0   2018-06-12 [1] CRAN (R 4.1.0)                    
#>  pillar        1.7.0   2022-02-01 [1] CRAN (R 4.1.2)                    
#>  pkgbuild      1.2.0   2020-12-15 [2] CRAN (R 4.1.0)                    
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.0)                    
#>  pkgload       1.2.4   2021-11-30 [1] CRAN (R 4.1.0)                    
#>  prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.1.0)                    
#>  processx      3.5.2   2021-04-30 [1] CRAN (R 4.1.0)                    
#>  ps            1.6.0   2021-02-28 [1] CRAN (R 4.1.0)                    
#>  purrr       * 0.3.4   2020-04-17 [1] CRAN (R 4.1.0)                    
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.1.0)                    
#>  Rcpp          1.0.8   2022-01-13 [1] CRAN (R 4.1.2)                    
#>  readr       * 2.1.2   2022-01-30 [1] CRAN (R 4.1.2)                    
#>  readxl        1.3.1   2019-03-13 [1] CRAN (R 4.1.0)                    
#>  remotes       2.4.0   2021-06-02 [2] CRAN (R 4.1.0)                    
#>  reprex        2.0.1   2021-08-05 [1] CRAN (R 4.1.0)                    
#>  rlang         1.0.1   2022-02-03 [1] CRAN (R 4.1.2)                    
#>  rmarkdown     2.11    2021-09-14 [1] CRAN (R 4.1.0)                    
#>  rprojroot     2.0.2   2020-11-15 [2] CRAN (R 4.1.0)                    
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.1.0)                    
#>  rvest         1.0.2   2021-10-16 [1] CRAN (R 4.1.0)                    
#>  sass          0.4.0   2021-05-12 [1] CRAN (R 4.1.0)                    
#>  scales        1.1.1   2020-05-11 [1] CRAN (R 4.1.0)                    
#>  sessioninfo   1.1.1   2018-11-05 [2] CRAN (R 4.1.0)                    
#>  stringi       1.7.6   2021-11-29 [1] CRAN (R 4.1.0)                    
#>  stringr     * 1.4.0   2019-02-10 [1] CRAN (R 4.1.0)                    
#>  testthat      3.1.2   2022-01-20 [1] CRAN (R 4.1.2)                    
#>  tibble      * 3.1.6   2021-11-07 [1] CRAN (R 4.1.0)                    
#>  tidyr       * 1.2.0   2022-02-01 [1] CRAN (R 4.1.2)                    
#>  tidyselect    1.1.1   2021-04-30 [1] CRAN (R 4.1.0)                    
#>  tidyverse   * 1.3.1   2021-04-15 [1] CRAN (R 4.1.0)                    
#>  tzdb          0.1.2   2021-07-20 [2] CRAN (R 4.1.0)                    
#>  usethis       2.0.1   2021-02-10 [2] CRAN (R 4.1.0)                    
#>  utf8          1.2.2   2021-07-24 [1] CRAN (R 4.1.0)                    
#>  vctrs         0.3.8   2021-04-29 [1] CRAN (R 4.1.0)                    
#>  withr         2.4.3   2021-11-30 [1] CRAN (R 4.1.0)                    
#>  xfun          0.29    2021-12-14 [1] CRAN (R 4.1.0)                    
#>  xml2          1.3.3   2021-11-30 [1] CRAN (R 4.1.0)                    
#>  yaml          2.2.2   2022-01-25 [1] CRAN (R 4.1.2)                    
#> 
#> [1] /Users/sebastiansaueruser/Library/R/x86_64/4.1/library
#> [2] /Library/Frameworks/R.framework/Versions/4.1/Resources/library