Home > Mobile >  How to manipulate data frame to better format which is usable in ggplot?
How to manipulate data frame to better format which is usable in ggplot?

Time:11-21

I am working through some messy data where, after reading it in, it appears as the following:

> glimpse(il_births)
Rows: 106
Columns: 22
$ x1989       <dbl> 190247, 928, 175, 187, 445, 57, 425, 41, 207, 166, 2662, 48…
$ x1990       <dbl> 195499, 960, 192, 195, 462, 68, 449, 53, 222, 187, 2574, 47…
$ x1991       <dbl> 194066, 971, 164, 195, 464, 72, 448, 54, 179, 211, 2562, 49…
$ x1992       <dbl> 190923, 881, 189, 185, 462, 72, 414, 55, 201, 161, 2426, 46…
$ x1993       <dbl> 190709, 893, 152, 206, 497, 50, 389, 75, 202, 183, 2337, 43…
$ x1994       <dbl> 189182, 865, 158, 200, 538, 58, 429, 48, 189, 171, 2240, 41…
$ x1995       <dbl> 185801, 828, 140, 202, 566, 58, 417, 48, 173, 166, 2117, 43…
$ x1996       <dbl> 183079, 830, 147, 194, 529, 58, 417, 49, 175, 150, 2270, 41…
$ x1997       <dbl> 180649, 812, 132, 193, 531, 64, 389, 37, 163, 185, 2175, 43…
$ x1998       <dbl> 182503, 862, 140, 201, 545, 41, 417, 57, 185, 188, 2128, 41…
$ x1999       <dbl> 182027, 843, 117, 188, 595, 51, 396, 47, 193, 191, 2194, 39…
$ x2000       <dbl> 185003, 825, 132, 184, 587, 63, 434, 51, 170, 181, 2260, 40…
$ x2001       <dbl> 184022, 866, 138, 196, 629, 57, 420, 49, 147, 215, 2312, 39…
$ x2002       <dbl> 180555, 760, 129, 172, 629, 54, 434, 48, 191, 185, 2226, 39…
$ x2003       <dbl> 182393, 794, 141, 239, 668, 76, 458, 58, 154, 208, 2288, 39…
$ x2004       <dbl> 180665, 802, 126, 209, 646, 56, 396, 51, 151, 181, 2291, 42…
$ x2005       <dbl> 178872, 883, 122, 189, 744, 54, 409, 58, 160, 199, 2490, 40…
$ x2006       <dbl> 180503, 805, 112, 215, 737, 57, 392, 55, 140, 177, 2455, 41…
$ x2007       <dbl> 180530, 890, 136, 185, 736, 60, 413, 49, 163, 195, 2508, 44…
$ x2008       <dbl> 176634, 817, 120, 173, 676, 64, 409, 59, 142, 200, 2482, 40…
$ x2009       <dbl> 171077, 804, 114, 198, 622, 65, 381, 53, 123, 164, 2407, 40…
$ county_name <chr> "ILLINOIS TOTAL", "ADAMS", "ALEXANDER", "BOND", "BOONE", "B…

The data comes from enter image description here

Created on 2022-11-20 with reprex v2.0.2

  • Related