challenge_1
railroads
faostat
wildbirds
Author

Nanci Kopecky

Published

February 21, 2023

Code
library(tidyverse)

knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE)

Challenge Overview

Today’s challenge is to

  1. read in a dataset, and

  2. describe the dataset using both words and any supporting information (e.g., tables, etc)

Read in the Data

Read in one (or more) of the following data sets, using the correct R package and command.

  • railroad_2012_clean_county.csv ⭐
  • birds.csv ⭐⭐
  • FAOstat*.csv ⭐⭐
  • wild_bird_data.xlsx ⭐⭐⭐
  • StateCounty2012.xls ⭐⭐⭐⭐

Find the _data folder, located inside the posts folder. Then you can read in the data, using either one of the readr standard tidy read commands, or a specialized package such as readxl. ###Reading in Railroad data I had to set the working directory in order for this code to work.

Code
library(readr)
railroad<-read.csv(file = "_data/railroad_2012_clean_county.csv",
                header=TRUE,
                sep = ","
                )

Add any comments or documentation as needed. More challenging data sets may require additional code chunks and documentation.

My comment is that I was able to read in the data after I set the working directory. I selected Session, Set Working Directly, then Choose Directly.

Describe the data

Using a combination of words and results of R commands, can you provide a high level description of the data? Describe as efficiently as possible where/how the data was (likely) gathered, indicate the cases and variables (both the interpretation and any details you deem useful to the reader to fully understand your chosen data).

Exploring some commands.

Code
head(railroad)
  state               county total_employees
1    AE                  APO               2
2    AK            ANCHORAGE               7
3    AK FAIRBANKS NORTH STAR               2
4    AK               JUNEAU               3
5    AK    MATANUSKA-SUSITNA               2
6    AK                SITKA               1
Code
nrow(railroad)
[1] 2930
Code
ncol(railroad)
[1] 3
Code
railroad$total_employees
   [1]    2    7    2    3    2    1   88  102  143    1   25  154   13   29
  [15]   45   13    9   72    7   26   10    7   14  199   11    5   12    5
  [29]  129   11  122   33  116   47   78    3   40    8    7    8    1   46
  [43]   55  990   25  117   11   46    7    7    6   29   16   17   29  331
  [57]   43  102   42    4   24   19   39   38  158  162    9   42   19   60
  [71]  192   11   11   45    1   11   18   25   35    5    8    5    3   40
  [85]   13    8   79    5   19   61   55   48   30   12   15   34  289    5
  [99]   54   68  167   15    6   79   37   32    4   13  361    7   11   32
 [113]    3   54   22    4  330    7    8   10   18    7    2   15    1   15
 [127]   22   11   10    4   17   31    5  972   19  262    3   43   50   20
 [141]   16    2   20    2   46  102    9  270   60  268   37   48    3   10
 [155]  462  407  510  749  154   18   63   94  346    9   69   30    2  348
 [169]  103  341    4    2   65  500   21    2   14 2545   39   12    4    6
 [183]   59    3    1   29   17   36  460  539   84 1567  738   13 2888  206
 [197]   61  474   98   80   36  244   44   69    2   83  221   38  195   54
 [211]   10    2   97    9   68   62   88  553   10  128    2    3    1   71
 [225]   42    6    1    2    6    1    7    3   16  503    1  112   10  129
 [239]   10   28   13    5   10    1   10  267    3    2    1    2  159   77
 [253]    5  137  252    6    2   10   34  141   12    4    1   26  526   10
 [267]   30    2   16    6    6    3  223    3  486  113   57  137 1561  146
 [281]   26   66  279  158 1275   62   22   81   45   20   33  294    1   10
 [295]   23  636   14   35    9    2 3073  124   29    2    5    1    5    6
 [309]   11    2    1   30   15  387    6   12   12    3    5   77   43   21
 [323]    6    1    1   23   48    9  346    7  242    6   12  101   30  155
 [337]   71   73  238   34   48   18   92  449   56   36   11    5   11  175
 [351]    4    3   13   24   22   56   11    1   32  114  120   12  304   17
 [365]  112    4   95   42   17   23    3   41    4  130  120   35  281    4
 [379]    4  129    9    2  194   16  661   85    5   89    4  116    6   12
 [393]   31    3   11  315    9    6   43  282    6  130    1   33    5    9
 [407]  177   31   40    6  878    6    1   40   33    9    5  372   12   55
 [421]    4   21   37   10    4  269   89   24   38   13   12   11   17    4
 [435]   42   19   10   11   22   28   15    4   87    2    4    6    7   32
 [449]    7   78    2    6   63    4    2    6   84    9    7    3  200   47
 [463]   16  271   17   65    3   10    4   12  206   60    7    7    2   33
 [477]    8    3    9   13    4   11    5    9   30   13   28    1   53    7
 [491]   12   18   54  117  413    8   34   94    3    3   22   15    7   22
 [505]   11    1    2    1    5    7   18   13    1   39  116  206   17   35
 [519]    2   23   16   38   13   19  157    2    7   16    2   24  140    8
 [533]   46   11    9   18  179    2   71    6   23   34   11   15   19    9
 [547]   10   31   10   20  102   26    1   17    1   13   26   24   10   37
 [561]   14    3    5  204  146    7    5    2   12    3   14   90   96   15
 [575]   12   14   19   29    1    1   13    2   14    5  235  609    7   13
 [589]   10  137   12    1   94   20    3   70    8   42   37   10    5   65
 [603]    6    1  155   12   36   81    2  538   71   10   47    3   40   44
 [617]   44  168   12   16    1    1    9   20    1   26    4    4    6   11
 [631]  205   11    2    6   32   13    8    7   23   12   63    1   21  116
 [645]    2   23   44    7   35    4   96   66  131  104   24   14   38   42
 [659] 8207   12    9   46  119   60  837   45   12    4   33   32   23   39
 [673]   56    7   13   83   19  127    1  100   74   87   37    4   72   14
 [687]   14   26  577  289  122  885  132  340    6   40   12   16  425   79
 [701]  427  261   10   23    9   53  273   45   10   18  122   38   43   49
 [715]   75  130   20   54   50    1    7    5   68    9   94   11  114   32
 [729]   15   45  495    5   33   71   41  178   14  188   29   18   16  124
 [743] 1784   53   76   14   11  536   12    6   24   22    7   26   35  131
 [757]   28   28   21   35   50    7  118  125   35  306   19   85   21   10
 [771]    8  153   39   72   63   60  147  229   35   34   66   11   80   18
 [785]   10   13  165   16   30   16 1999  360   24   16   70  703   40    3
 [799]  146   27   30  105   18   59    5    7   19   10    7   27  550   41
 [813]   11   41   23    8    7   10   43   23  258   58   45   34  118   14
 [827]    7  221   23  103   30    8   82   29   12   39   23   38   16   12
 [841]   42   11   22   47   14   76   11    1   38    5   14   10    1   94
 [855]  205    3  138   24  126    4    7   12    3    9   22   72   24    1
 [869]    3    3    1   14  153   19    4   56  122    1 1286   12    1   88
 [883]  232    2   31    6   91   46  233   34    5  113    2  111   54   22
 [897]   16    2   73    1   12    1   25   17   34    2   67    2    7   30
 [911]    9   10    1  107    3  325   12  856    9    2    3    1    3  168
 [925]    3    2   21    9   22    2    4    7  415    1    5    5    7    5
 [939]    3   27  236    8  232   62   11   36   14  125    1   29    4   79
 [953]    7   19   54   18   15    6    7    1    1   31    5    1   42   58
 [967]    9   84    5    4    8    8   91   24   11    4  483    3   67   44
 [981]   15    6   48   24    3  133    4  413   13   50  244   16   38    7
 [995]  113   97    8    3   22   55  113   11   16    6   47    1    7   22
[1009]   16    8   84    7    5   28    1   55    1    4    5    1   22   59
[1023]   11   16   35    3    2   31   39  231    6  104    2   32    4    5
[1037]   15   33    1   22    2   15    3    4    7   12    3    2   10  322
[1051]    3    5   13   19  103    5   37   43   21  285  546  280    7    1
[1065]    1   31    3   40  285    1   11   11    4   25   25   86   20  368
[1079]    6    5  124   10   16   78   10   19   22  240  128   17   67  158
[1093]    6    2    8   35   46   11   38   91   31    2  128  105    1   14
[1107]    8    5   42   20   68   73    3    5    2   44   50  232  314  113
[1121]  202   68  673  386  429  558  310  509  406  415  103    8  118  393
[1135]  112    8  157   53  248   79  722    3  302  809   22    1   94    2
[1149]  127   12    6   22   57   71    2    3  109    5    7   36  117   75
[1163]    8   67   11   17   47    1    8   27    3   19    4   16   58    2
[1177]  136   13  164   89    2    8    5   10    1  188    7   42    1  195
[1191]    4    3    4    5   17    6    9   46   32   13    3    5   77   58
[1205]    3  149    1   36    3   70   33    2    2  170   12  137   17    5
[1219]   14    5  266   17   24   15  265    1    6   11    2    1    1   40
[1233]    1    2   80   14   13  100  109   42   38   27   63  849    5   19
[1247]  346   62   10   20   10   59   25  181   41   20    6   91  175    9
[1261]    4  143  348    1   44    8    4   24   35    3  651   42   14   57
[1275]   37    7   10  157    4   43    2   68    6   27    4   10    7   13
[1289]    3   46   32   34   43   20    3    6    6    9   18   54   62   35
[1303]    5  106   43  579   10    9   13   37    9    4   72  148   11  595
[1317]  100   16    9   16   28    2   13    9   49  207   32   34   26   62
[1331]    5   21   17    5   25   17   26   12   29   12   52  150   84   38
[1345]   15   11   86   23   20  235   10   50  112   29  681   97   46   60
[1359]   17   19    8   21   36    2    1   24   54   14    5  362   23   19
[1373]   20    3   16    7   87  226   13 2055  127  436   42   16   18   74
[1387]   64   20   18  140   44   47   30    1   93    5    9   15    1   24
[1401]   24    9   24   10   38    7  132   12    5    3   29   95   18   33
[1415]   98   38    5    1   23  138  126    5   48   27   27    8    1  126
[1429]   10   12  166    8  202  316   47   20    6   19   34   25    8   50
[1443]   38   86    3   40    3   45   16   33   12   14   11    6    3   15
[1457]   10    1   16    8  341   64   12   21    2   15   57   46  130   23
[1471]    3    1    7   42   10    4   10    6    5   27  169   15    6   23
[1485]    1   46   79   45   24   50   65   15    3   47    8   10   13   67
[1499]   11   56    3    1    5  104   12    1   15    8    2    3   36    8
[1513]   10    3    8    5   49    4   18    6    5   16   10    7    8    5
[1527]   32    4   40  199    9   61    2  301   18    4   11  367   30   29
[1541]    2    8  513    8    2   46   83    9   31    1    1    1   14  362
[1555]    3   64    9   25    3    9   11   49   26    9   84   37    7   20
[1569]   52    7    5   28    2  143    1    7  525   14   10    1   12    3
[1583]    4    4    7   22   94   15   84    5   10    5    7   22    3    8
[1597]    2    1   12   17   14   39   29    3   90   28    4   24    7   77
[1611]    5   55    6    2    8   78   36   15   21   32    3    4   48    8
[1625]   56    8    5   19   66    4   26  224   13   22   41  205   45   15
[1639]    4   15    1   16   18    2    2   19    5   18  291  122   12  228
[1653]   30    5   30   49    9   30    3    4   50    4  322    6    6    1
[1667]   15    1   49    6   23    2   25    2    6    1    7  317  373    2
[1681]   11   12    1    7    2   14    4  173    5    2    1    9    5    2
[1695]   78   10    1   34  191   14    6    2    4    9   14   70    8   58
[1709]    6    3    8    1    2   34   48   11   76  407  101   25   77    2
[1723]    2    8    2    2 1168    1  107    9   40  192    8    2    1   68
[1737]   13    4    4   82   35  120  142   13    5   78 3797    5   13    3
[1751]   30   18  152   21    9    8    3  135   14    4    3   15    3   17
[1765]   21   42   30    6   98   24    9 1619 2289   35    1   45   19   14
[1779]  112    1   12    8   71    7   20    7    7   92    8  124   66    1
[1793]   41  840  123  614  114   49   18    1   11   22    5    1   13   75
[1807]    3    5   18    2   12   28   19    7  136    9  146   27    7   58
[1821]  513  464  427   19   39 1097  270  871   68  361  955  862  296  589
[1835]  231   30  148  178  738  115  227    4   14   27   25  431    7   91
[1849]   43   13    8   11    4    7   41  240   45   42    2   58   56    6
[1863]   80   26    3   12   29    5  401    5  269   77   47    8    5   26
[1877]   42   12    5    1  249  629   55  648  141   72   36   57   21   39
[1891]   24  126   11   25 1157  784   27   11   20   46  196   48   19  970
[1905]    5   71   43  131   36 2076  373  119   72  184   33  342   11   91
[1919]   89  317 1470  358  177   89  233  149   43    7   13   79   99 3685
[1933]   14   32    8  211   26   60   46 1040   50    6   24   92   56  270
[1947]   21   23   22   14  220   25   28   23   68   25  211   87  112  552
[1961]   16   33   58  213   53   18  359   60   19   29   19   16  278   71
[1975]   22   26   38   15    9    4  674   14  108   17  114  305   49   54
[1989]  280  842   20  176   60  117   20    8   24    4   83    3   21   29
[2003]    3  151   18   12   40   39   51   12   58  251   40  129  451  175
[2017]   21  335  140  121  133   54   16    6   69   22   65   42  316   35
[2031]    2    5    4    1   11    7   49   24   59    8    6   32   41    5
[2045]   15    3   17   75   38   14    2    7  161   11   55   12    5    1
[2059]    8    9    3    5    8   66    7    2   43  176   18   19   11    5
[2073]   29   19   27   18   18    7  127   10   34    7  193   34    1   14
[2087]   11    9   23   37   21   11   72    6   48    9    7  377   19   31
[2101]    6   20   23   37   15  127    4   48   10    8   53   39    2    2
[2115]   14   30   10    8  228    4  229    4  103   10   85   39  349   11
[2129]    2    7  467  196    6   50   87   38   39  760   39  566  138  195
[2143]  910   38 1106  136  420    4  121   32  308   22  120   39    3   67
[2157]  299  357  815    7  140  291   64    3   29   47   36   67   67  109
[2171]  350  173   70  145   85   58    8   84   53  207  532    3  229  102
[2185]  169 1649   88    5  131   26  149   84   15   19   16   10  195   51
[2199]  392   17  260    8  102   11  318   48  124  193    1   34    6    9
[2213]   17   94    2  148    9   15   24   18   29   53   74  139   17   22
[2227]  220   29  139   94   25   42    7   26   19   20    4  118   22   19
[2241]   20   28    5   25   48   87    5  124   29   19   22   72    1   82
[2255]    2    1   34  127    5    4    1    1    5   13   60    6    4    3
[2269]    2    1    9  167    5    3    6    3    9    1   17    1    1   13
[2283]    3   19   10    1    2   69    1  106    2   49    1    1   10    8
[2297]    2    5    4    1    5   52    6    5   45   12   24   10  128   72
[2311]   57    8   57   21   16    3   32   37   12   16   14  162    1    6
[2325]   64   18   30    5   36   25   10   53   43   59   62  429    2   14
[2339]   10   57    4   14   22   16   24    2   60    1  458    2   44   42
[2353]    6    4   26   22  115   40  111  114   17   10   46   27   60   37
[2367]    1    2    2   41    3   70   44   78  171   45   11   51  621    7
[2381]    2   72   88   45    2  230   23    3    6  164    3   39    3   77
[2395]   74  241    3   53    6    8   12   64   35    5   15  102    1    9
[2409]  413  950    3   17   64  259   55   14    3   39   21    6   25    7
[2423]   12  119   14   21   54    9   57   17   11  159    4   16  132   15
[2437]    1   56   87    1    2   13  130  406    7    2  394    6    2    1
[2451]    1    1   16   20    1  863  125   20   20   19   26    2    2    1
[2465]  258   87   20  283    2    2    5   42   22  151  154    9   69   10
[2479]    7    2    1    8  141 2535   98    9   33   37   39   78    7  102
[2493]   22   21   75    7   32   37   33    8   30    2  244    4   11  429
[2507]    7    3   49   10    5   35   20    1   14   26    4    9   14   12
[2521]   31  144   24    4    3  292    2    8   14    2    2   12   71    4
[2535]  148   56   30   37    4   11   17  474   49   16   17   37   25   14
[2549]   34   82    8  105   31   21  303   28    2   27  883    9    5   72
[2563]    2    1    3    2   30   32   10   13    5    3   24   38    5    9
[2577]   17    1  127    5    2    1    1   13 4235   86   15    5   10   52
[2591]   74    6   29   41    2   35   93   47   60   38   21    5    4  291
[2605]   13    4  120    4    1   77   75  156   60    2    2    4   85   58
[2619]   23   52    2  337   10    8    1   48   25    8   18    5  580    8
[2633]    5    1   12   52   10  186    7   16  360    4   28  108   10   28
[2647]   16   63   12   12  395   14  288    9   25   32   43   46    3    6
[2661]   30  228    2   31   24    5   15   23    4  225   24   43    9  202
[2675]   24   41   14   15    4    2   10  117  128   24 3249   36    6    6
[2689]    6   29    1   32   42   31   43    3    3    7    2  101   12   29
[2703]    7  106   35   70    9   49   28   34   13  110   33    9    1  193
[2717]   16   40  172   30   13   15   26   46   37   10  197   22   26    7
[2731]  114   39   20    8    8    3   40    4   83    5    4    9   13   59
[2745]    3   10   10   15   17  294   79    8  850    2  151    2    1  148
[2759]    1   22   29   39    4 1039   60   15   63   73   12   20   15    6
[2773]   21  614    2   57   14  506  757   34   94    3   45   45    9   56
[2787]   29    7   20   11   76   16    6    8   35    9  106   24   74   63
[2801]    2  465   13   78  275   16   33   11   17    5    4   19   27   14
[2815]  111    4  339    7    7   23   15   23   12   36  188   51   16   13
[2829]   57    6   12   43   23  240   10  100  138   21   29   14    9    9
[2843]  168   15   54   48    5   47   23   37   96   34   13   95  119   33
[2857]  108   50   22   19  406    4    4   30    1    7   75   37   37    7
[2871]   51   22   56  130    3  107   61   16   26   34   43  387  223  168
[2885]   19   35   33    6   25    3   13   35   83   98   21    7    3  153
[2899]   94    2    2    5  217    5    9    7  108   63   90   70  386  168
[2913]  211   33   42  244    4   18  737   25   92   51   29  129  252    3
[2927]  196   49   10   37
Code
mean(railroad$total_employees)
[1] 87.17816
Code
railroad %>%
  summarize(
    mean_employees=mean(total_employees),
    median_employees=median(total_employees),
    sd_employees=sd(total_employees))
  mean_employees median_employees sd_employees
1       87.17816               21     283.6359

The railroad data has 3 variables (State, County, Total Employees) and 2930 observations. The code below is exploring some commands.

The mean is 87 employees and the median is 21, wow, there must be some extreme values! And the standard deviation is 284.

Visualize the Data

I was wondering about the extreme values for the railroad county employees. The box plot shows the outliers and the histogram shows the right tail.

Code
boxplot(railroad$total_employees)

Code
hist(railroad$total_employees)