5 📚 Summarizing Data
Let’s do some more practice. Download the dca_weather
dataset, which gives the minimum and maximum temperatures in Arlington, VA, and also the amount of rainfall each day. This data is taken from NOAA’s Website.
STATION | NAME | year | month | day | TAVG | TMAX | TMIN | AWND | PRCP | SNOW | SNWD |
---|---|---|---|---|---|---|---|---|---|---|---|
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 1 | 57 | 66 | 53 | 4.70 | 0.44 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 2 | 60 | 63 | 46 | 9.62 | 0.13 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 3 | 38 | 46 | 25 | 14.54 | 0.99 | 6.9 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 4 | 30 | 34 | 23 | 5.82 | 0.00 | 0.0 | 7.1 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 5 | 34 | 41 | 27 | 8.95 | 0.00 | 0.0 | 3.9 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 6 | 40 | 44 | 36 | 7.61 | 0.00 | 0.0 | 2.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 7 | 32 | 36 | 25 | 12.30 | 0.19 | 2.6 | 3.1 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 8 | 27 | 33 | 22 | 7.61 | 0.00 | 0.0 | 1.2 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 9 | 35 | 47 | 30 | 10.74 | 0.58 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 10 | 38 | 44 | 28 | 14.54 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 11 | 27 | 30 | 22 | 9.84 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 12 | 32 | 47 | 23 | 9.62 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 13 | 39 | 52 | 31 | 2.91 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 14 | 43 | 50 | 34 | 14.76 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 15 | 29 | 34 | 20 | 12.97 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 16 | 22 | 40 | 17 | 12.75 | 0.90 | 2.6 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 17 | 37 | 42 | 34 | 17.22 | 0.02 | 0.0 | 1.2 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 18 | 37 | 42 | 30 | 9.84 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 19 | 39 | 55 | 30 | 11.41 | 0.03 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 20 | 42 | 46 | 27 | 10.51 | 0.28 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 21 | 25 | 27 | 19 | 13.42 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 22 | 24 | 34 | 16 | 7.38 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 23 | 31 | 40 | 24 | 5.59 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 24 | 36 | 41 | 31 | 7.83 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 25 | 39 | 51 | 30 | 9.62 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 26 | 30 | 35 | 24 | 10.51 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 27 | 27 | 36 | 20 | 6.26 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 28 | 34 | 41 | 31 | 6.49 | 0.12 | 0.2 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 29 | 28 | 33 | 22 | 19.69 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 30 | 24 | 32 | 18 | 6.04 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 1 | 31 | 30 | 39 | 25 | 7.61 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 1 | 32 | 44 | 25 | 4.25 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 2 | 36 | 49 | 29 | 4.47 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 3 | 44 | 57 | 40 | 5.37 | 0.50 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 4 | 50 | 62 | 35 | 13.20 | 1.08 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 5 | 33 | 35 | 26 | 14.99 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 6 | 29 | 39 | 23 | 4.92 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 7 | 36 | 44 | 32 | 5.14 | 0.07 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 8 | 40 | 50 | 31 | 6.26 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 9 | 40 | 54 | 30 | 6.93 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 10 | 48 | 62 | 37 | 7.61 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 11 | 48 | 67 | 33 | 8.95 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 12 | 54 | 62 | 44 | 10.51 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 13 | 39 | 44 | 28 | 10.51 | 0.05 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 14 | 29 | 33 | 25 | 10.51 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 15 | 30 | 39 | 21 | 6.93 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 16 | 37 | 54 | 28 | 8.50 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 17 | 54 | 70 | 47 | 14.99 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 18 | 54 | 68 | 31 | 18.34 | 0.01 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 19 | 37 | 51 | 26 | 14.99 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 20 | 31 | 43 | 23 | 9.17 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 21 | 44 | 66 | 32 | 7.61 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 22 | 53 | 66 | 42 | 11.41 | 0.07 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 23 | 65 | 77 | 42 | 14.32 | 0.01 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 24 | 40 | 42 | 33 | 10.07 | 0.35 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 25 | 39 | 59 | 33 | 12.08 | 0.19 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 26 | 38 | 44 | 33 | 9.17 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 27 | 43 | 56 | 35 | 6.49 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 2 | 28 | 45 | 51 | 36 | 8.95 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 1 | 41 | 55 | 32 | 7.83 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 2 | 51 | 63 | 40 | 5.14 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 3 | 51 | 57 | 35 | 14.32 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 4 | 38 | 48 | 28 | 8.05 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 5 | 45 | 61 | 36 | 6.93 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 6 | 62 | 78 | 50 | 13.65 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 7 | 70 | 80 | 54 | 18.12 | 0.03 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 8 | 53 | 54 | 44 | 11.86 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 9 | 44 | 47 | 40 | 8.50 | 0.77 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 10 | 44 | 53 | 36 | 5.82 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 11 | 49 | 63 | 38 | 8.50 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 12 | 41 | 50 | 24 | 16.11 | 0.58 | 0.9 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 13 | 29 | 44 | 21 | 10.96 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 14 | 44 | 61 | 32 | 8.05 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 15 | 53 | 71 | 42 | 7.16 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 16 | 58 | 73 | 45 | 4.92 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 17 | 55 | 61 | 50 | 7.61 | 0.86 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 18 | 57 | 74 | 47 | 8.28 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 19 | 65 | 76 | 57 | 13.87 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 20 | 59 | 62 | 50 | 14.99 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 21 | 56 | 71 | 44 | 8.28 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 22 | 59 | 71 | 47 | 5.59 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 23 | 53 | 55 | 49 | 9.40 | 0.49 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 24 | 54 | 57 | 51 | 7.83 | 0.02 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 25 | 55 | 64 | 49 | 7.83 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 26 | 51 | 54 | 41 | 11.63 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 27 | 42 | 46 | 32 | 16.55 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 28 | 35 | 42 | 28 | 15.66 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 29 | 34 | 48 | 25 | 9.84 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 30 | 45 | 60 | 35 | 6.71 | 0.02 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 3 | 31 | 61 | 75 | 51 | 17.00 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 1 | 58 | 65 | 46 | 13.87 | 0.21 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 2 | 48 | 58 | 39 | 8.72 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 3 | 52 | 62 | 44 | 12.30 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 4 | 48 | 59 | 39 | 7.16 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 5 | 52 | 56 | 48 | 7.38 | 0.84 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 6 | 56 | 62 | 53 | 9.62 | 0.86 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 7 | 53 | 54 | 48 | 9.62 | 0.68 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 8 | 54 | 65 | 45 | 8.28 | 0.15 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 9 | 51 | 58 | 44 | 9.62 | 0.04 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 10 | 48 | 56 | 41 | 10.96 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 11 | 51 | 67 | 40 | 6.71 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 12 | 63 | 80 | 53 | 5.82 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 13 | 69 | 86 | 56 | 9.62 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 14 | 75 | 84 | 60 | 14.54 | 0.03 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 15 | 62 | 72 | 50 | 9.84 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 16 | 66 | 80 | 59 | 13.42 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 17 | 57 | 59 | 46 | 13.87 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 18 | 46 | 48 | 40 | 11.63 | 0.91 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 19 | 46 | 55 | 40 | 13.65 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 20 | 50 | 62 | 41 | 7.61 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 21 | 56 | 68 | 49 | 10.74 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 22 | 64 | 77 | 52 | 5.37 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 23 | 65 | 78 | 53 | 5.82 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 24 | 66 | 82 | 55 | 6.93 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 25 | 61 | 72 | 54 | 8.95 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 26 | 62 | 74 | 57 | 6.93 | 0.10 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 27 | 56 | 63 | 43 | 14.32 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 28 | 48 | 60 | 39 | 13.42 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 29 | 54 | 67 | 42 | 6.04 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 4 | 30 | 56 | 68 | 44 | 5.82 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 1 | 59 | 67 | 53 | 5.82 | 0.13 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 2 | 64 | 79 | 54 | 4.92 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 3 | 65 | 74 | 58 | 9.62 | 0.36 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 4 | 63 | 74 | 57 | 5.14 | 0.52 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 5 | 64 | 69 | 58 | 6.71 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 6 | 61 | 64 | 53 | 11.18 | 1.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 7 | 54 | 55 | 47 | 16.55 | 1.29 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 8 | 50 | 58 | 44 | 13.87 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 9 | 56 | 71 | 43 | 8.28 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 10 | 62 | 74 | 49 | 10.51 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 11 | 64 | 75 | 51 | 9.62 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 12 | 65 | 75 | 57 | 8.50 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 13 | 67 | 76 | 63 | 7.83 | 0.14 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 14 | 69 | 71 | 65 | 4.70 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 15 | 69 | 81 | 63 | 6.26 | 0.44 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 16 | 69 | 82 | 64 | 7.61 | 0.27 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 17 | 71 | 84 | 57 | 10.51 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 18 | 67 | 75 | 58 | 6.93 | 0.01 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 19 | 71 | 86 | 61 | 6.49 | 0.03 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 20 | 77 | 89 | 67 | 7.61 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 21 | 83 | 92 | 73 | 8.72 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 22 | 80 | 89 | 69 | 10.51 | 1.50 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 23 | 70 | 75 | 62 | 10.74 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 24 | 62 | 64 | 59 | 10.07 | 0.32 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 25 | 64 | 72 | 57 | 9.84 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 26 | 66 | 73 | 61 | 5.59 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 27 | 71 | 79 | 66 | 9.62 | 0.33 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 28 | 71 | 80 | 63 | 8.05 | 0.02 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 29 | 74 | 82 | 63 | 4.92 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 30 | 77 | 88 | 67 | 8.50 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 5 | 31 | 82 | 96 | 71 | 5.82 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 1 | 85 | 94 | 74 | 6.93 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 2 | 80 | 89 | 72 | 6.71 | 0.46 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 3 | 73 | 80 | 67 | 9.62 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 4 | 75 | 86 | 61 | 6.26 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 5 | 73 | 80 | 64 | 8.72 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 6 | 72 | 81 | 61 | 8.05 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 7 | 71 | 80 | 64 | 8.50 | 0.20 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 8 | 77 | 88 | 69 | 5.82 | 0.02 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 9 | 77 | 84 | 67 | 11.86 | 0.06 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 10 | 72 | 83 | 61 | NA | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 11 | 70 | 73 | 65 | NA | 0.07 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 12 | 71 | 81 | 67 | 7.38 | 0.01 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 13 | 80 | 94 | 72 | 4.70 | 0.01 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 14 | 79 | 85 | 73 | 7.61 | 0.04 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 15 | 80 | 89 | 70 | 6.93 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 16 | 79 | 85 | 74 | 11.41 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 17 | 84 | 99 | 73 | 10.96 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 18 | 77 | 79 | 67 | 16.11 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 19 | 70 | 80 | 60 | 14.32 | 0.00 | 0.0 | 0.0 |
USW00013743 | WASHINGTON REAGAN NATIONAL AIRPORT, VA US | 2022 | 6 | 20 | 72 | NA | NA | NA | NA | NA | NA |
5.1 Quantitative Variables: mean()
, median()
, fivenum()
, IQR()
, and sd()
These functions do exactly as they sound, however, you must pass a numeric vector through each of them.
#This will return an error-- since dca_weather
#has multiple columns, R doesn't know which column you want.
mean(dca_weather)
## Warning in mean.default(dca_weather): argument is not
## numeric or logical: returning NA
## [1] NA
mean(dca_weather$TAVG)
## [1] 53.13
Knowing the average temperature from January to June is pretty useless though– sometimes, you want to filter it by month.
## [1] 75.85
If the command looks intimidating, consider the command from inside out.
- In the square brackets, you consider only the rows where
dca_weather$months
is equal to 6. Those pass on a set of rows todca_weather$TAVG
. - Then, you pass only those rows, and select the
dca_weather$TAVG
data from those rows. That passes on a vector tomean()
. - Finally, you calculate the mean of all those numbers.
The median()
and fivenum()
commands work the same.
## [1] 21.0 27.0 32.0 35.5 47.0
## [1] 75
Finally, sd()
and IQR()
will give you measures of spread.
## [1] 10.79
## [1] 7.25
5.1.1 The dreaded NA
response
Consider the following code:
## [1] NA
Why does it return back NA
? Well it turns out that if you look examine the data for June… it turns out that there are some NAs within the vector we are trying to process. Any time you perform a mathematical operation with NA in R, R will always return back NA– it’s like a special value that obliterates everything else in its path.
dca_weather[169:171,]
## # A tibble: 3 × 12
## STATION NAME year month day TAVG TMAX TMIN AWND
## <chr> <chr> <dbl> <dbl> <int> <dbl> <dbl> <dbl> <dbl>
## 1 USW00013… WASH… 2022 6 18 77 79 67 16.1
## 2 USW00013… WASH… 2022 6 19 70 80 60 14.3
## 3 USW00013… WASH… 2022 6 20 72 NA NA NA
## # … with 3 more variables: PRCP <dbl>, SNOW <dbl>,
## # SNWD <dbl>
At this point, we have a choice to make. Obviously, the data for June 20th wasn’t available when I downloaded it, because I downloaded this data on June 23rd. In this case though, it doesn’t make sense to treat NA
as 0, because clearly the temperature wasn’t 0 degrees in June. However, we can still draw conclusions about the data that we have, and so we can tell R to ignore any NAs
in the data.
## [1] 6.306
Notice that the argument na.rm=
is passed into the sd()
argument. Try typing ?sd()
to read the documentation on this function.
5.2 Categorical Variables: The table()
function
Let’s say I’m interested in how many elements are in gas, liquid, and solid state at room temperature. Looking at the periodic_table
columns, I see that the column that gives me that information is state_at_stp
.
table(periodic_table$state_at_stp)
##
## Gas Liquid Solid
## 11 2 90
You should only use
table()
for categorical data, because it returns a counts to you. Counting quanatitative variables is meaningless.The table function takes a single vector, or two vectors, into the function. Do not pass an entire table through table(), or else R will return an error.
The table function provides a count of the number of elements that appear in each state. But as you can see, the ordering is off.
5.3 Making code efficient with piping and dplyr
The following code does the same exact thing as the previous command, using the dyplr
package and the piping operator.2
library(dplyr)
dca_weather %>%
dplyr::filter(month==6) %>%
dplyr::select(TMAX) %>%
summarize(average=mean(TMAX, na.rm=TRUE), std_dev=sd(TMAX, na.rm=TRUE))
## # A tibble: 1 × 2
## average std_dev
## <dbl> <dbl>
## 1 84.7 6.31
Although it is one more thing to learn, it is more powerful and sustainable in the long run. In fact, most help guides you’ll see on the internet will use the pipe
operator and the dplyr functions filter
and `select. Some advantages:
- Unlike in base R, where the first command is on the inside, and you work your way out, piping allows you to see the first command on the top.
- Piping also passes the dataframe name to the next command, so you don’t need to retype the dataset name each time.
- The
dplyr::filter()
function also makes quick work of selecting only the rows that you need, rather than using a combination of[]
,%in
, and$
. - And finally, the summarize command allows you to not just calculate one statistic, but many statistics at once.
Finally, dplyr allows us to do more powerful things like the group_by
function. Now, we can find the mean, median, and standard deviation of all 6 months with just one command.
library(dplyr)
dca_weather %>%
dplyr::group_by(month) %>%
dplyr::select(TMAX) %>%
summarize(average=mean(TMAX, na.rm=TRUE), median=median(TMAX, na.rm=TRUE), std_dev=sd(TMAX, na.rm=TRUE))
## # A tibble: 6 × 4
## month average median std_dev
## <dbl> <dbl> <dbl> <dbl>
## 1 1 42.0 41 9.10
## 2 2 53.1 52.5 11.6
## 3 3 60.5 61 10.8
## 4 4 66.6 65 9.97
## 5 5 76.4 75 9.49
## 6 6 84.7 84 6.31