Loops size estimates by name apply (solution)

Exercise
Output solution

Part 1

Rows: 500 Columns: 2
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): species
dbl (1): lengths

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
  [1]  24341.681         NA         NA  22114.190         NA         NA
  [7]  57349.470  14160.494  49677.749  42105.917  10221.747  15339.988
 [13]  70624.102  23883.825  28552.864  18801.370  19438.673         NA
 [19]  19607.970  16032.845         NA  50350.112  15969.078  29582.848
 [25]  15201.456  12980.541   9937.867   9599.415  49245.963  23846.751
 [31]  53805.661  53326.467         NA  15554.977  18544.119         NA
 [37]         NA  82492.318  17909.041  38694.503  80303.181  19592.802
 [43]  10614.785  29560.809  71658.477         NA  83961.661         NA
 [49]  26284.040  21766.002  63571.873   5480.255  33917.314  22778.032
 [55]  13819.165  21154.149  17635.099  14577.594         NA  14032.340
 [61]  30231.694         NA  11293.886  72743.800  23679.901  64258.574
 [67]  14931.085  16323.818         NA         NA         NA   7599.703
 [73]         NA         NA         NA         NA  46920.035  70529.031
 [79]   9484.528         NA  68340.494  44959.626         NA  48249.486
 [85]  11730.174         NA  52295.177         NA         NA         NA
 [91]  40358.292  38891.137  30878.439  19125.425         NA         NA
 [97]   8697.216  19627.357         NA         NA  13411.390  33157.499
[103]  10874.733  24554.930  16819.494  18421.449         NA  19645.723
[109]  38206.241  53196.019  22346.109         NA  22685.103         NA
[115]  13613.983  34685.790         NA  18654.525         NA 101482.428
[121]  89149.257         NA  20820.837         NA  22232.852  59702.598
[127]         NA  16321.774  22748.880         NA         NA         NA
[133]         NA  25987.768  49818.253  13106.766         NA  32112.443
[139]         NA  16984.463  10859.926  93973.020  52342.265  19151.788
[145]         NA  13954.186         NA  15021.820  35933.327 140435.607
[151]  20467.332  23869.639         NA         NA  15211.979  57098.945
[157]  23588.700  27381.008  85932.513         NA   9331.295         NA
[163]         NA  32005.502  16613.444   7904.857         NA  26352.263
[169]  19880.480  15543.679  15493.654  13546.034         NA  36095.081
[175]  42437.608         NA         NA  51637.913         NA  44120.181
[181]   9535.583  59840.348         NA         NA         NA  44822.176
[187]  14232.684  34751.496  11292.437         NA         NA         NA
[193]  22002.082  19554.166  13223.770         NA         NA  68935.505
[199]   9172.206  90096.476  25796.762  50594.426  61952.966  20132.528
[205]         NA  13979.439  15481.074  12104.000  21789.436  54009.090
[211]  13812.364   8071.939  21144.506  44097.848  16250.303  70065.996
[217]  11170.349  22826.560  40885.088  17292.043  18394.391  50267.629
[223]  70791.032  28464.276  41431.346         NA  14242.918         NA
[229]         NA  52014.366  32865.058         NA  11906.150  17964.362
[235]  14844.497  13079.836  76048.107  18843.875         NA  30737.511
[241]  37983.026  18711.957  22636.970  29868.755  42799.606         NA
[247]  43632.463 103600.943         NA         NA  10330.761  23659.805
[253]  19126.024  17175.845  28017.230  54437.041         NA  20657.057
[259]  13275.051         NA   8222.362         NA 108964.075         NA
[265]   5845.741  26356.588         NA  59636.239  14857.582  45043.701
[271]  47427.024         NA         NA  11807.182  27575.709  18177.367
[277]         NA  22108.648  33908.940         NA         NA         NA
[283]         NA  45862.941  23366.240  16165.694  10263.470         NA
[289]  24026.928  33497.651         NA  15770.110  48190.121  33107.401
[295]  20523.437  21387.730  15771.706  12632.938  28352.199  10401.651
[301]  41162.369  16740.472  29576.590  28831.907  21622.906         NA
[307]  26736.709  18663.882  10872.689  13072.222  35308.681  17145.703
[313]  19620.530   1550.370         NA  11509.202  16574.358  94984.150
[319]   9448.048  56370.430         NA  47899.078  27521.456  24907.229
[325]  12800.024  34456.895         NA  19137.794   9084.302         NA
[331]  20396.019   7636.822  15452.482         NA  11482.576         NA
[337]  21323.042  17062.973  24482.018  19394.529  61929.256         NA
[343]  29113.203  53044.431  17891.216  21665.733  21611.857  13917.623
[349]  21715.000         NA  10525.601  31777.548  45932.499  16396.801
[355]         NA  21020.829   9499.589         NA  11886.269  13597.168
[361]         NA  32610.060  50496.496  23180.857  20838.975  27426.143
[367]  51655.501  52241.022  27527.983  40947.425  26691.614  23152.573
[373]  43419.737  44236.593  60396.602  15878.961  70561.697  17374.235
[379]  10332.362  34844.884         NA  43839.492         NA  10259.928
[385]  24344.124         NA  23490.643  15151.289  40052.674  31011.453
[391]         NA  36300.595  28716.671  21434.730         NA  27977.292
[397]  13912.492         NA         NA  45387.391  21638.866  12782.316
[403]         NA         NA         NA  74279.377  19250.194  19647.872
[409]  39022.265         NA         NA   9446.876  33097.292         NA
[415]  23694.389  15501.027  13490.363   7311.070  63156.403  40543.550
[421]  19942.976         NA         NA  26888.995         NA  18102.809
[427] 125939.133         NA         NA  14393.863         NA  62045.506
[433]  60194.052  36753.957         NA         NA  32061.537         NA
[439]  67466.670  17627.746  24171.682  25917.752  67098.902         NA
[445]  17699.295  18903.752  13127.745  17295.450  42209.926  23426.667
[451] 118937.988         NA  18165.832         NA  46816.660         NA
[457]  53237.908  23121.375  25937.746         NA  47637.068         NA
[463] 127540.554         NA  12313.099  24276.516  15500.675  16109.794
[469]  15965.471  54296.492         NA         NA  14365.977 153749.934
[475]  59143.016  18524.301   6227.675  13606.978         NA         NA
[481]  49146.996 103896.484  38059.728  41076.716         NA  30013.153
[487]  41805.513  20113.277  24071.440         NA         NA   8489.727
[493]  24349.181         NA         NA  44921.367  26262.993  16883.382
[499]  14444.693         NA

Part 2


Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
# A tibble: 500 × 3
# Rowwise: 
   species      lengths masses
   <chr>          <dbl>  <dbl>
 1 Stegosauria     18.5 24342.
 2 Ankylosauria    16.4    NA 
 3 Ankylosauria    23.7    NA 
 4 Sauropoda       23.9 22114.
 5 Ankylosauria    21.7    NA 
 6 Ankylosauria    21.4    NA 
 7 Theropoda       22.3 57349.
 8 Theropoda       15.2 14160.
 9 Theropoda       21.4 49678.
10 Stegosauria     22.8 42106.
# ℹ 490 more rows

Part 3

`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Warning: Removed 138 rows containing non-finite outside the scale range
(`stat_bin()`).