4  Types of dataset

4.1 Cross-sectional data

Here is an example of a cross-sectional dataset. Notice that you have one observation for each unit only. You might have several variables for each unit. Usually, when you create a plot, you will have two variables, one in each axis.

library(ggplot2)
library(ggthemes)
mtcars <- mtcars
ggplot(mtcars, aes(hp, mpg, color = am)) +
  geom_point() +  geom_smooth(formula = y ~ x, method = "loess") +   theme_solarized()
Warning: The following aesthetics were dropped during statistical transformation: colour
ℹ This can happen when ggplot fails to infer the correct grouping structure in
  the data.
ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
  variable into a factor?

knitr::kable(head(mtcars,30))
mpg cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4
Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4
Datsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1
Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1
Hornet Sportabout 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2
Valiant 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1
Duster 360 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4
Merc 240D 24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2
Merc 230 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2
Merc 280 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4
Merc 280C 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4
Merc 450SE 16.4 8 275.8 180 3.07 4.070 17.40 0 0 3 3
Merc 450SL 17.3 8 275.8 180 3.07 3.730 17.60 0 0 3 3
Merc 450SLC 15.2 8 275.8 180 3.07 3.780 18.00 0 0 3 3
Cadillac Fleetwood 10.4 8 472.0 205 2.93 5.250 17.98 0 0 3 4
Lincoln Continental 10.4 8 460.0 215 3.00 5.424 17.82 0 0 3 4
Chrysler Imperial 14.7 8 440.0 230 3.23 5.345 17.42 0 0 3 4
Fiat 128 32.4 4 78.7 66 4.08 2.200 19.47 1 1 4 1
Honda Civic 30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2
Toyota Corolla 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 1
Toyota Corona 21.5 4 120.1 97 3.70 2.465 20.01 1 0 3 1
Dodge Challenger 15.5 8 318.0 150 2.76 3.520 16.87 0 0 3 2
AMC Javelin 15.2 8 304.0 150 3.15 3.435 17.30 0 0 3 2
Camaro Z28 13.3 8 350.0 245 3.73 3.840 15.41 0 0 3 4
Pontiac Firebird 19.2 8 400.0 175 3.08 3.845 17.05 0 0 3 2
Fiat X1-9 27.3 4 79.0 66 4.08 1.935 18.90 1 1 4 1
Porsche 914-2 26.0 4 120.3 91 4.43 2.140 16.70 0 1 5 2
Lotus Europa 30.4 4 95.1 113 3.77 1.513 16.90 1 1 5 2
Ford Pantera L 15.8 8 351.0 264 4.22 3.170 14.50 0 1 5 4
Ferrari Dino 19.7 6 145.0 175 3.62 2.770 15.50 0 1 5 6

4.2 Time-series data

Here is an example of a Time-series dataset. Notice that you have one observation per period. You need to pay attention to the frequency when you have time-series. Usually, when you create a plot, you will have the period variable as the x-axis.

library(GetQuandlData)
library(GetTDData)
api_key <- "kfqxH5NsN8Nhe_U1NADB"
first_date <- '2020-01-01'
last_date <- '2022-01-01'
inf <- get_Quandl_series(id_in =  c('Inflation' = 'BCB/433'),
                               api_key = api_key, 
                               first_date = first_date,
                               last_date = last_date)
library(ggplot2)
library(ggthemes)
ggplot(inf, aes( x = ref_date, y= value)) + geom_line() + labs(title = "Selic")+
   theme(axis.text.x = element_text(color = "grey20", size = 15, angle = 0, hjust = .5, vjust = .5, face = "plain"),
        axis.text.y = element_text(color = "grey20", size = 15, angle = 0, hjust = 1, vjust = 0, face = "plain"),  
        axis.title.x = element_text(color = "grey20", size = 15, angle = 0, hjust = .5, vjust = 0, face = "plain"),
        axis.title.y = element_text(color = "grey20", size = 15, angle = 90, hjust = .5, vjust = .5, face = "plain")) +   theme_solarized()

knitr::kable(inf)
series_name ref_date value id_quandl
Inflation 2020-01-31 0.21 BCB/433
Inflation 2020-02-29 0.25 BCB/433
Inflation 2020-03-31 0.07 BCB/433
Inflation 2020-04-30 -0.31 BCB/433
Inflation 2020-05-31 -0.38 BCB/433
Inflation 2020-06-30 0.26 BCB/433
Inflation 2020-07-31 0.36 BCB/433
Inflation 2020-08-31 0.24 BCB/433
Inflation 2020-09-30 0.64 BCB/433
Inflation 2020-10-31 0.86 BCB/433
Inflation 2020-11-30 0.89 BCB/433
Inflation 2020-12-31 1.35 BCB/433
Inflation 2021-01-31 0.25 BCB/433
Inflation 2021-02-28 0.86 BCB/433
Inflation 2021-03-31 0.93 BCB/433
Inflation 2021-04-30 0.31 BCB/433
Inflation 2021-05-31 0.83 BCB/433
Inflation 2021-06-30 0.53 BCB/433
Inflation 2021-07-31 0.96 BCB/433
Inflation 2021-08-31 0.87 BCB/433
Inflation 2021-09-30 1.16 BCB/433
Inflation 2021-10-31 1.25 BCB/433
Inflation 2021-11-30 0.95 BCB/433
Inflation 2021-12-31 0.73 BCB/433

4.3 Pooled cross sections data

A pooled cross section dataset combines more than one cross-sectional dataset collected overtime. For instance, when you have data from two non consecutive years. It is hard to create a graph with this dataset, but you can manage to include more than one year in the same plot.

More about the dataset here

library(ggplot2)
library(ggthemes)
library(wooldridge)
Warning: package 'wooldridge' was built under R version 4.2.3
data('infmrt')
ggplot(infmrt, aes(pcinc, infmort, color=factor(year), group=factor(year))) +   geom_point() + theme_solarized()  

knitr::kable(infmrt)
year infmort afdcprt popul pcinc physic afdcper d90 lpcinc lphysic DC lpopul
1987 8.3 52 1186 13996 173 4.384486 0 9.546527 5.153292 0 7.078341
1990 6.2 62 1228 17125 178 5.048860 1 9.748295 5.181784 0 7.113142
1987 7.8 11 1056 18083 186 1.041667 0 9.802728 5.225747 0 6.962244
1990 7.1 21 1109 21051 200 1.893598 1 9.954703 5.298317 0 7.011214
1987 8.5 20 547 14267 244 3.656307 0 9.565704 5.497168 0 6.304449
1990 6.4 25 563 17630 253 4.440497 1 9.777357 5.533390 0 6.333280
1987 7.2 234 5856 19131 322 3.995902 0 9.859065 5.774551 0 8.675222
1990 7.0 282 6016 22558 337 4.687500 1 10.023845 5.820083 0 8.702178
1987 8.4 42 986 15683 244 4.259635 0 9.660333 5.497168 0 6.893656
1990 8.1 52 1003 18771 254 5.184447 1 9.840069 5.537334 0 6.910751
1987 8.8 107 3212 21258 293 3.331258 0 9.964489 5.680172 0 8.074649
1990 7.9 135 3287 25528 305 4.107089 1 10.147531 5.720312 0 8.097731
1987 10.7 1019 17835 17943 307 5.713485 0 9.794955 5.726848 0 9.788918
1990 9.6 1031 17990 22068 315 5.730962 1 10.001883 5.752573 0 9.797571
1987 9.4 320 7674 20277 234 4.169924 0 9.917242 5.455321 0 8.945593
1990 9.0 323 7730 24977 246 4.178525 1 10.125711 5.505331 0 8.952864
1987 10.4 539 11942 15198 227 4.513482 0 9.628919 5.424950 0 9.387816
1990 9.6 549 11882 18725 235 4.620434 1 9.837615 5.459586 0 9.382780
1987 9.3 648 10816 14575 191 5.991124 0 9.587063 5.252274 0 9.288782
1990 9.8 657 10847 17422 196 6.056974 1 9.765489 5.278115 0 9.291644
1987 10.1 150 5530 13987 151 2.712477 0 9.545883 5.017280 0 8.617943
1990 9.6 164 5544 16814 157 2.958153 1 9.729967 5.056246 0 8.620472
1987 11.6 681 11584 16394 210 5.878799 0 9.704671 5.347107 0 9.357380
1990 10.7 656 11431 20327 212 5.738780 1 9.919705 5.356586 0 9.344084
1987 10.7 642 9205 15558 180 6.974471 0 9.652330 5.192957 0 9.127502
1990 10.7 684 9295 18297 185 7.358795 1 9.814492 5.220356 0 9.137232
1987 8.6 271 4807 14674 181 5.637612 0 9.593833 5.198497 0 8.477828
1990 8.2 236 4892 17455 189 4.824203 1 9.767382 5.241747 0 8.495357
1987 8.7 161 4244 15789 212 3.793591 0 9.667068 5.356586 0 8.353262
1990 7.3 177 4375 18690 220 4.045714 1 9.835744 5.393628 0 8.383662
1987 9.1 104 2823 14028 145 3.684024 0 9.548811 4.976734 0 7.945555
1990 8.1 96 2777 16848 151 3.456968 1 9.731987 5.017280 0 7.929126
1987 10.2 200 5107 14630 190 3.916193 0 9.590830 5.247024 0 8.538367
1990 9.4 218 5117 17347 196 4.260309 1 9.761175 5.278115 0 8.540323
1987 8.7 15 671 12825 167 2.235469 0 9.459151 5.117994 0 6.508769
1990 8.0 16 639 15158 170 2.503912 1 9.626284 5.135798 0 6.459905
1987 9.9 18 709 12414 138 2.538787 0 9.426580 4.927254 0 6.563856
1990 10.1 19 696 15566 140 2.729885 1 9.652844 4.941642 0 6.545350
1987 8.6 43 1594 14100 168 2.697616 0 9.553930 5.123964 0 7.374002
1990 8.3 44 1578 17276 172 2.788340 1 9.757073 5.147494 0 7.363913
1987 9.5 67 2475 15089 169 2.707071 0 9.621721 5.129899 0 7.813996
1990 8.4 77 2478 17768 175 3.107345 1 9.785154 5.164786 0 7.815207
1987 11.7 20 648 16305 191 3.086420 0 9.699227 5.252274 0 6.473891
1990 10.1 22 666 20709 199 3.303303 1 9.938324 5.293305 0 6.501290
1987 11.5 176 4536 18217 325 3.880070 0 9.810110 5.783825 0 8.419801
1990 9.5 198 4781 21915 334 4.141393 1 9.994927 5.811141 0 8.472405
1987 19.3 50 621 19543 591 8.051530 0 9.880372 6.381816 1 6.431331
1990 20.7 54 607 23885 615 8.896211 1 10.081006 6.421622 1 6.408529
1987 10.2 145 5914 16539 204 2.451809 0 9.713476 5.318120 0 8.685078
1990 10.2 158 6187 19679 213 2.553742 1 9.887307 5.361292 0 8.730206
1987 9.8 111 1898 11013 164 5.848261 0 9.306831 5.099866 0 7.548556
1990 9.9 109 1793 13722 166 6.079197 1 9.526755 5.111988 0 7.491645
1987 11.9 171 6409 13353 179 2.668123 0 9.499496 5.187386 0 8.765458
1990 10.6 255 6629 16383 190 3.846734 1 9.704000 5.247024 0 8.799210
1987 12.7 122 3426 12078 156 3.561004 0 9.399141 5.049856 0 8.139149
1990 11.7 118 3487 15043 161 3.383998 1 9.618668 5.081404 0 8.156797
1987 12.7 244 6227 14387 167 3.918420 0 9.574081 5.117994 0 8.736650
1990 12.4 320 6478 17041 175 4.939796 1 9.743378 5.164786 0 8.776167
1987 10.6 307 12022 15594 203 2.553652 0 9.654641 5.313206 0 9.394494
1990 9.6 420 12938 18606 208 3.246251 1 9.831240 5.337538 0 9.467924
1987 9.7 155 3723 11996 161 4.163309 0 9.392328 5.081404 0 8.222285
1990 8.5 204 3685 14984 168 5.535956 1 9.614738 5.123964 0 8.212026
1987 11.7 181 4855 12977 187 3.728115 0 9.470934 5.231109 0 8.487764
1990 10.3 230 4877 15869 196 4.716014 1 9.672123 5.278115 0 8.492286
1987 12.2 132 4084 12039 151 3.232125 0 9.395906 5.017280 0 8.314832
1990 10.8 132 4041 14899 158 3.266518 1 9.609050 5.062595 0 8.304248
1987 13.7 176 2624 10301 125 6.707317 0 9.239996 4.828314 0 7.872455
1990 12.1 176 2573 12700 133 6.840264 1 9.449357 4.890349 0 7.852828
1987 10.3 67 2388 11421 144 2.805695 0 9.343209 4.969813 0 7.778212
1990 9.2 73 2351 14037 150 3.105062 1 9.549452 5.010635 0 7.762596
1987 11.8 271 4448 11506 184 6.092626 0 9.350624 5.214936 0 8.400209
1990 11.1 279 4220 14300 188 6.611374 1 9.568015 5.236442 0 8.347590
1987 9.6 101 3259 12607 145 3.099110 0 9.442007 4.976734 0 8.089175
1990 9.2 129 3146 15154 147 4.100445 1 9.626019 4.990433 0 8.053887
1987 9.1 500 16781 13840 169 2.979560 0 9.535318 5.129899 0 9.728003
1990 8.1 673 16987 16600 175 3.961853 1 9.717158 5.164786 0 9.740204
1987 10.0 29 909 12304 150 3.190319 0 9.417680 5.010635 0 6.812345
1990 9.0 29 799 14663 158 3.629537 1 9.593082 5.062595 0 6.683361
1987 10.4 18 1000 11797 120 1.800000 0 9.375601 4.787492 0 6.907755
1990 8.7 17 1007 15137 125 1.688183 1 9.624897 4.828314 0 6.914731
1987 9.2 13 490 12836 134 2.653061 0 9.460009 4.897840 0 6.194406
1990 8.6 16 454 16467 139 3.524229 1 9.709114 4.934474 0 6.118097
1987 9.8 94 3293 15680 202 2.854540 0 9.660141 5.308268 0 8.099554
1990 8.8 109 3294 18795 211 3.309047 1 9.841346 5.351858 0 8.099858
1987 8.1 60 1496 11889 173 4.010695 0 9.383368 5.153292 0 7.310550
1990 9.0 67 1515 14124 183 4.422442 1 9.555631 5.209486 0 7.323171
1987 9.5 91 3400 14322 191 2.676471 0 9.569552 5.252274 0 8.131531
1990 8.8 144 3665 16169 197 3.929059 1 9.690851 5.283204 0 8.206584
1987 8.8 44 1680 11530 177 2.619048 0 9.352708 5.176150 0 7.426549
1990 7.5 47 1723 14036 185 2.727800 1 9.549380 5.220356 0 7.451822
1987 9.6 17 1006 16359 158 1.689861 0 9.702534 5.062595 0 6.913737
1990 8.4 25 1202 19680 159 2.079867 1 9.887358 5.068904 0 7.091742
1987 9.7 208 4542 15634 206 4.579480 0 9.657204 5.327876 0 8.421123
1990 7.8 237 4867 18738 213 4.869529 1 9.838309 5.361292 0 8.490233
1987 10.4 81 2723 13906 196 2.974660 0 9.540075 5.278115 0 7.909490
1990 8.3 99 2842 17038 205 3.483462 1 9.743201 5.323010 0 7.952263
1987 9.0 1708 27653 17770 242 6.176545 0 9.785267 5.488938 0 10.227490
1990 7.9 2023 29760 20547 244 6.797715 1 9.930471 5.497168 0 10.300921
1987 10.4 19 524 18461 138 3.625954 0 9.823416 4.927254 0 6.261492
1990 10.5 24 550 20867 146 4.363637 1 9.945924 4.983607 0 6.309918
1987 8.9 41 1082 15569 225 3.789279 0 9.653037 5.416100 0 6.986567
1990 6.7 44 1108 20461 236 3.971119 1 9.926276 5.463832 0 7.010312

4.4 Panel dataset

When you have a Panel, you have both dimensions: a cross-sectional and a time-series. That is, you have several variables from several units through several years. This is the type of dataset that most finance and accounting research deals with.

library(wooldridge)
data('prison')
knitr::kable(head(prison,50))
state year govelec black metro unem criv crip lcriv lcrip gcriv gcrip y81 y82 y83 y84 y85 y86 y87 y88 y89 y90 y91 y92 y93 ag0_14 ag15_17 ag18_24 ag25_34 incpc polpc gincpc gpolpc cag0_14 cag15_17 cag18_24 cag25_34 cunem cblack cmetro pris lpris gpris final1 final2
1 80 0 0.2560 0.6320000 0.08775 4.447868 44.47638 1.492425 3.794958 0.0987858 0.1747851 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2408834 0.0575244 0.1322547 0.1538264 7673.176 235.0026 0.0896345 0.0541870 -0.0012273 -0.0011926 0.0000768 0.0019899 0.01675 -0.0599995 0.0002000 141.3347 4.951131 -0.0206594 0 0
1 81 0 0.2557 0.6362000 0.10667 4.700944 44.24879 1.547763 3.789828 0.0553384 -0.0051301 1 0 0 0 0 0 0 0 0 0 0 0 0 0.2367951 0.0546058 0.1324317 0.1584588 8442.723 227.2263 0.0955742 -0.0336498 -0.0040883 -0.0029186 0.0001770 0.0046324 0.01892 -0.0300007 0.0042000 163.5336 5.097019 0.1458879 0 0
1 82 1 0.2554 0.6404000 0.14367 4.497580 42.05045 1.503539 3.738870 -0.0442240 -0.0509582 0 1 0 0 0 0 0 0 0 0 0 0 0 0.2336306 0.0519745 0.1317197 0.1584713 8855.808 219.4395 0.0477686 -0.0348701 -0.0031645 -0.0026312 -0.0007120 0.0000126 0.03700 -0.0299988 0.0042000 183.6948 5.213276 0.1162572 0 0
1 83 0 0.2551 0.6446000 0.13667 4.186833 37.08439 1.431945 3.613196 -0.0715947 -0.1256738 0 0 1 0 0 0 0 0 0 0 0 0 0 0.2313167 0.0495679 0.1304016 0.1596340 9411.027 222.5979 0.0608087 0.0142903 -0.0023139 -0.0024066 -0.0013181 0.0011626 -0.00700 -0.0300007 0.0042000 218.6242 5.387354 0.1740785 0 0
1 84 0 0.2548 0.6488000 0.11167 4.353239 35.04226 1.470920 3.556555 0.0389756 -0.0566416 0 0 0 1 0 0 0 0 0 0 0 0 0 0.2279858 0.0485830 0.1277834 0.1609312 10267.680 214.3978 0.0871189 -0.0375338 -0.0033309 -0.0009849 -0.0026182 0.0012972 -0.02500 -0.0300007 0.0042000 245.0686 5.501538 0.1141839 0 0
1 85 0 0.2545 0.6530001 0.08908 4.630758 35.26680 1.532721 3.562942 0.0618004 0.0063875 0 0 0 0 1 0 0 0 0 0 0 0 0 0.2252706 0.0488296 0.1240876 0.1625975 10974.390 220.5386 0.0665633 0.0282399 -0.0027152 0.0002466 -0.0036958 0.0016664 -0.02259 -0.0299988 0.0042001 259.2611 5.557836 0.0562973 0 0
1 86 1 0.2542 0.6572000 0.09833 5.665331 37.87350 1.734365 3.634252 0.2016448 0.0713096 0 0 0 0 0 1 0 0 0 0 0 0 0 0.2224449 0.0501002 0.1197395 0.1638276 11666.695 226.8036 0.0611739 0.0280116 -0.0028257 0.0012706 -0.0043481 0.0012301 0.00925 -0.0300007 0.0042000 270.5512 5.600461 0.0426259 0 0
1 87 0 0.2539 0.6614000 0.07775 5.686924 39.58107 1.738170 3.678351 0.0038042 0.0440993 0 0 0 0 0 0 1 0 0 0 0 0 0 0.2204234 0.0500623 0.1160648 0.1643836 12289.268 241.1706 0.0519881 0.0614201 -0.0020215 -0.0000379 -0.0036747 0.0005559 -0.02058 -0.0300007 0.0042000 288.1763 5.663573 0.0631113 0 0
1 88 0 0.2536 0.6656000 0.07208 5.728628 41.05592 1.745476 3.714935 0.0073066 0.0365839 0 0 0 0 0 0 0 1 0 0 0 0 0 0.2196819 0.0487078 0.1135686 0.1635189 13052.042 256.2624 0.0602183 0.0606973 -0.0007415 -0.0013545 -0.0024962 -0.0008647 -0.00567 -0.0299988 0.0042000 313.8730 5.748989 0.0854158 0 0
1 89 0 0.2533 0.6698000 0.07025 6.036973 41.25161 1.797903 3.719690 0.0524266 0.0047555 0 0 0 0 0 0 0 0 1 0 0 0 0 0.2191067 0.0464020 0.1116625 0.1620347 13967.873 268.8834 0.0678153 0.0480757 -0.0005752 -0.0023058 -0.0019061 -0.0014841 -0.00183 -0.0300007 0.0042001 307.0825 5.727117 -0.0218720 0 0
1 90 1 0.2530 0.6740000 0.06775 7.069136 41.96889 1.955738 3.736928 0.1578355 0.0172381 0 0 0 0 0 0 0 0 0 1 0 0 0 0.2182716 0.0449383 0.1098765 0.1597531 14896.788 280.4938 0.0643857 0.0422741 -0.0008351 -0.0014637 -0.0017860 -0.0022817 -0.00250 -0.0300007 0.0042000 336.8486 5.819634 0.0925169 0 0
1 91 0 0.2527 0.6782000 0.07200 8.439609 45.20342 2.132936 3.811173 0.1771978 0.0742443 0 0 0 0 0 0 0 0 0 0 1 0 0 0.2176039 0.0442543 0.1092910 0.1574572 15600.990 288.9731 0.0461888 0.0297819 -0.0006677 -0.0006840 -0.0005856 -0.0022959 0.00425 -0.0299988 0.0042000 379.3827 5.938545 0.1189117 0 0
1 92 0 0.2524 0.6824000 0.07300 8.712421 43.94321 2.164750 3.782898 0.0318139 -0.0282745 0 0 0 0 0 0 0 0 0 0 0 1 0 0.2153214 0.0439826 0.1087482 0.1546641 16494.385 290.0435 0.0556856 0.0036972 -0.0022825 -0.0002717 -0.0005428 -0.0027931 0.00100 -0.0300007 0.0042000 400.9780 5.993906 0.0553613 0 0
1 93 0 0.2521 0.6866000 0.07500 7.804156 40.98352 2.054657 3.713170 -0.1100934 -0.0697281 0 0 0 0 0 0 0 0 0 0 0 0 1 0.2135180 0.0437067 0.1084309 0.1523764 17105.346 296.8474 0.0363710 0.0231873 -0.0018034 -0.0002759 -0.0003173 -0.0022877 0.00200 -0.0300007 0.0042001 409.3282 6.014517 0.0206108 0 0
2 80 0 0.0340 0.4340000 0.09592 4.773632 57.03980 1.563108 4.043749 -0.0358539 -0.0089197 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2686567 0.0547264 0.1492537 0.2263682 13784.794 315.9204 0.1159335 -0.1006689 -0.0092589 -0.0048270 0.0053331 0.0104873 0.00267 0.0400002 0.0016000 132.0099 4.882877 0.0871882 0 0
2 81 0 0.0347 0.4317000 0.09233 6.069378 58.93301 1.803256 4.076401 0.2401487 0.0326519 1 0 0 0 0 0 0 0 0 0 0 0 0 0.2679426 0.0526316 0.1387560 0.2344498 15385.251 305.9809 0.1098432 -0.0319677 -0.0007141 -0.0020948 -0.0104978 0.0080816 -0.00359 0.0699999 -0.0023000 142.0398 4.956107 0.0732303 0 0
2 82 1 0.0354 0.4294000 0.09983 6.071111 54.39778 1.803542 3.996323 0.0002855 -0.0800779 0 1 0 0 0 0 0 0 0 0 0 0 0 0.2644444 0.0488889 0.1311111 0.2355556 17119.225 280.0000 0.1067928 -0.0887330 -0.0034981 -0.0037427 -0.0076449 0.0011058 0.00750 0.0699999 -0.0023000 170.5742 5.139170 0.1830630 0 0
2 83 0 0.0361 0.4271000 0.10308 6.024590 53.05123 1.795849 3.971258 -0.0076922 -0.0250652 0 0 1 0 0 0 0 0 0 0 0 0 0 0.2684426 0.0471311 0.1250000 0.2356557 17930.697 268.8524 0.0463121 -0.0406269 0.0039982 -0.0017577 -0.0061111 0.0001002 0.00325 0.0699999 -0.0023000 193.7778 5.266712 0.1275420 0 0
2 84 0 0.0368 0.4248000 0.10150 6.046692 53.43969 1.799511 3.978554 0.0036620 0.0072956 0 0 0 1 0 0 0 0 0 0 0 0 0 0.2704280 0.0466926 0.1206226 0.2315175 17625.547 286.1868 -0.0171648 0.0624819 0.0019854 -0.0004385 -0.0043774 -0.0041382 -0.00158 0.0700002 -0.0023000 219.6721 5.392136 0.1254239 0 0
2 85 0 0.0375 0.4225000 0.09608 5.697369 51.85714 1.740004 3.948493 -0.0595070 -0.0300610 0 0 0 0 1 0 0 0 0 0 0 0 0 0.2763158 0.0469925 0.1165414 0.2255639 18430.637 294.5489 0.0446649 0.0288003 0.0058878 0.0002999 -0.0040812 -0.0059536 -0.00542 0.0699999 -0.0023000 251.5564 5.527667 0.1355314 0 0
2 86 1 0.0382 0.4202000 0.10908 5.599265 55.71140 1.722635 4.020185 -0.0173692 0.0716918 0 0 0 0 0 1 0 0 0 0 0 0 0 0.2794118 0.0477941 0.1139706 0.2169118 17821.215 277.2059 -0.0336247 -0.0606844 0.0030960 0.0008016 -0.0025708 -0.0086521 0.01300 0.0699999 -0.0023000 287.5940 5.661550 0.1338820 0 0
2 87 0 0.0389 0.4179000 0.10800 4.435993 47.94249 1.489751 3.870002 -0.2328838 -0.1501825 0 0 0 0 0 0 1 0 0 0 0 0 0 0.2820037 0.0482375 0.1113173 0.2096475 17252.170 318.7384 -0.0324517 0.1396103 0.0025919 0.0004434 -0.0026533 -0.0072643 -0.00108 0.0700002 -0.0023000 306.2500 5.724402 0.0628524 0 0
2 88 0 0.0396 0.4156000 0.09225 4.948340 41.63469 1.599052 3.728934 0.1093006 -0.1410685 0 0 0 0 0 0 0 1 0 0 0 0 0 0.2785978 0.0442804 0.1070111 0.2084871 17932.758 355.7196 0.0386912 0.1097720 -0.0034059 -0.0039570 -0.0043062 -0.0011604 -0.01575 0.0699999 -0.0023000 327.8293 5.792493 0.0680909 0 0
2 89 0 0.0403 0.4133000 0.06742 4.795247 41.25594 1.567625 3.719795 -0.0314269 -0.0091383 0 0 0 0 0 0 0 0 1 0 0 0 0 0.2760512 0.0420475 0.1060329 0.2065813 19636.496 353.5649 0.0907608 -0.0060756 -0.0025466 -0.0022329 -0.0009782 -0.0019057 -0.02483 0.0700002 -0.0023000 343.5424 5.839311 0.0468178 0 0
2 90 1 0.0410 0.4110000 0.07025 5.207581 45.95126 1.650116 3.827581 0.0824903 0.1077862 0 0 0 0 0 0 0 0 0 1 0 0 0 0.2725632 0.0415162 0.1010830 0.2039711 20848.021 350.1805 0.0598692 -0.0096183 -0.0034880 -0.0005313 -0.0049499 -0.0026102 0.00283 0.0699997 -0.0023000 348.8117 5.854532 0.0152216 0 0
2 91 0 0.0417 0.4087000 0.08500 6.149385 50.96661 1.816352 3.931171 0.1662366 0.1035893 0 0 0 0 0 0 0 0 0 0 1 0 0 0.2759227 0.0404218 0.0984183 0.1968365 21581.395 273.6380 0.0345725 -0.2466428 0.0033595 -0.0010945 -0.0026648 -0.0071346 0.01475 0.0700002 -0.0023000 334.1155 5.811487 -0.0430455 1 0
2 92 0 0.0424 0.4064000 0.09100 6.593537 49.00680 1.886090 3.891959 0.0697378 -0.0392115 0 0 0 0 0 0 0 0 0 0 0 1 0 0.2738095 0.0425170 0.0969388 0.1887755 22235.414 233.8435 0.0298547 -0.1571537 -0.0021132 0.0020952 -0.0014795 -0.0080610 0.00600 0.0699997 -0.0023000 323.3743 5.778810 -0.0326762 0 1
2 93 0 0.0431 0.4041000 0.07600 7.607679 48.07178 2.029158 3.872695 0.1430682 -0.0192637 0 0 0 0 0 0 0 0 0 0 0 0 1 0.2721202 0.0434057 0.0968281 0.1803005 23014.133 275.9599 0.0344223 0.1656034 -0.0016893 0.0008887 -0.0001107 -0.0084750 -0.01500 0.0700002 -0.0023000 330.6122 5.800946 0.0221357 0 1
3 80 0 0.0280 0.7510000 0.06700 6.502207 75.12620 1.872142 4.319170 0.1653266 0.1067777 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2373068 0.0540839 0.1357616 0.1633554 9332.060 299.4849 0.1122263 0.0294920 -0.0058646 -0.0016824 0.0014672 0.0044024 0.01650 -0.0200000 0.0006000 141.7678 4.954191 0.0329189 0 0
3 81 0 0.0282 0.7549000 0.06125 5.723132 69.95551 1.744516 4.247859 -0.1276256 -0.0713100 1 0 0 0 0 0 0 0 0 0 0 0 0 0.2320285 0.0505338 0.1345196 0.1708185 10250.007 302.6335 0.0938226 0.0104583 -0.0052784 -0.0035501 -0.0012420 0.0074631 -0.00575 0.0200000 0.0039000 160.4121 5.077746 0.1235552 0 0
3 82 1 0.0284 0.7588000 0.09917 5.115917 65.45364 1.632357 4.181342 -0.1121595 -0.0665174 0 1 0 0 0 0 0 0 0 0 0 0 0 0.2290657 0.0477509 0.1321799 0.1726644 10476.102 294.6367 0.0218182 -0.0267793 -0.0029627 -0.0027829 -0.0023396 0.0018459 0.03792 0.0200000 0.0039000 185.0178 5.220452 0.1427059 0 0
3 83 0 0.0286 0.7627000 0.09117 4.931627 58.85483 1.595669 4.075074 -0.0366877 -0.1062684 0 0 1 0 0 0 0 0 0 0 0 0 0 0.2270125 0.0458067 0.1289997 0.1751432 11228.498 288.2115 0.0693584 -0.0220484 -0.0020533 -0.0019442 -0.0031803 0.0024788 -0.00800 0.0200000 0.0039000 209.2734 5.343641 0.1231894 0 0
3 84 0 0.0288 0.7666000 0.04933 5.137268 59.55983 1.636521 4.086981 0.0408524 0.0119076 0 0 0 1 0 0 0 0 0 0 0 0 0 0.2262798 0.0449951 0.1248777 0.1773720 12285.703 284.4799 0.0899812 -0.0130319 -0.0007327 -0.0008116 -0.0041219 0.0022289 -0.04184 0.0200002 0.0039001 227.1135 5.425450 0.0818086 0 0
3 85 0 0.0290 0.7705000 0.06508 6.030779 65.19818 1.796876 4.177432 0.1603549 0.0904503 0 0 0 0 1 0 0 0 0 0 0 0 0 0.2255025 0.0452261 0.1206030 0.1787060 13219.922 282.1294 0.0732887 -0.0082970 -0.0007772 0.0002310 -0.0042747 0.0013340 0.01575 0.0200000 0.0039000 249.2990 5.518653 0.0932031 0 0
3 86 1 0.0292 0.7744000 0.06925 6.600665 66.81227 1.887170 4.201887 0.0902942 0.0244551 0 0 0 0 0 1 0 0 0 0 0 0 0 0.2224909 0.0456469 0.1169891 0.1804716 13993.291 288.3011 0.0568531 0.0216396 -0.0030116 0.0004208 -0.0036139 0.0017656 0.00417 0.0200000 0.0039000 259.8304 5.560029 0.0413761 0 0
3 87 0 0.0294 0.7783000 0.06275 6.034914 64.78411 1.797562 4.171061 -0.0896088 -0.0308261 0 0 0 0 0 0 1 0 0 0 0 0 0 0.2234507 0.0448065 0.1137620 0.1800989 14526.112 288.7984 0.0373699 0.0017234 0.0009597 -0.0008404 -0.0032271 -0.0003727 -0.00650 0.0200000 0.0039000 273.2164 5.610264 0.0502353 0 0
3 88 0 0.0296 0.7822000 0.06258 5.982178 67.27242 1.788785 4.208750 -0.0087769 0.0376897 0 0 0 0 0 0 0 1 0 0 0 0 0 0.2240453 0.0432815 0.1117397 0.1790665 15063.988 291.7963 0.0363591 0.0103273 0.0005946 -0.0015250 -0.0020222 -0.0010324 -0.00017 0.0200000 0.0039000 307.1865 5.727455 0.1171908 0 0
3 89 0 0.0298 0.7861000 0.05225 5.886251 73.24241 1.772619 4.293775 -0.0161655 0.0850244 0 0 0 0 0 0 0 0 1 0 0 0 0 0.2274986 0.0411375 0.1098840 0.1758697 15639.458 294.1607 0.0374901 0.0080701 0.0034534 -0.0021440 -0.0018557 -0.0031968 -0.01033 0.0200000 0.0039000 341.2447 5.832600 0.1051445 0 0
3 90 1 0.0300 0.7900000 0.05325 6.495789 72.05352 1.871154 4.277409 0.0985348 -0.0163655 0 0 0 0 0 0 0 0 0 1 0 0 0 0.2292855 0.0404781 0.1070361 0.1722358 16254.542 298.6688 0.0385753 0.0152092 0.0017869 -0.0006594 -0.0028479 -0.0036339 0.00100 0.0200000 0.0039000 354.5831 5.870943 0.0383430 0 0
3 91 0 0.0302 0.7939000 0.05700 6.714362 67.42098 1.904249 4.210956 0.0330948 -0.0664530 0 0 0 0 0 0 0 0 0 0 1 0 0 0.2314469 0.0397758 0.1033102 0.1692472 16758.816 338.4410 0.0305521 0.1250145 0.0021614 -0.0007024 -0.0037259 -0.0029886 0.00375 0.0200000 0.0039000 375.7946 5.929043 0.0581002 0 0
3 92 0 0.0304 0.7978000 0.07400 6.708246 63.57751 1.903338 4.152260 -0.0009112 -0.0586963 0 0 0 0 0 0 0 0 0 0 0 1 0 0.2330376 0.0401879 0.1004697 0.1651879 17484.721 335.1775 0.0424029 -0.0096897 0.0015907 0.0004121 -0.0028405 -0.0040593 0.01700 0.0200000 0.0039000 397.5440 5.985306 0.0562630 0 0
3 93 0 0.0306 0.8017000 0.06200 7.149898 67.16743 1.967098 4.207189 0.0637605 0.0549288 0 0 0 0 0 0 0 0 0 0 0 0 1 0.2317073 0.0401423 0.0988313 0.1618394 18119.162 341.9969 0.0356427 0.0201417 -0.0013303 -0.0000456 -0.0016384 -0.0033485 -0.01200 0.0200000 0.0039000 416.1013 6.030929 0.0456228 0 0
4 80 1 0.1630 0.3870000 0.07608 3.349081 34.72878 1.208686 3.547569 -0.0485332 0.1058278 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2370954 0.0568679 0.1216098 0.1465442 7384.177 200.3937 0.0668903 0.0714786 -0.0020064 -0.0008159 0.0009581 0.0003531 0.01433 -0.2000008 0.0007000 131.2197 4.876873 0.1325030 0 0
4 81 0 0.1626 0.3884000 0.09100 3.104666 34.87658 1.132906 3.551816 -0.0757798 0.0042467 1 0 0 0 0 0 0 0 0 0 0 0 0 0.2333188 0.0532054 0.1229830 0.1504579 8304.127 192.8478 0.1174132 -0.0383827 -0.0037766 -0.0036625 0.0013732 0.0039137 0.01492 -0.0399990 0.0014000 127.3403 4.846863 -0.0300097 0 0
4 82 1 0.1622 0.3898000 0.09775 3.242371 35.42241 1.176305 3.567344 0.0433986 0.0155289 0 1 0 0 0 0 0 0 0 0 0 0 0 0.2306016 0.0501308 0.1233653 0.1495205 8646.841 194.9433 0.0404414 0.0108077 -0.0027172 -0.0030746 0.0003823 -0.0009374 0.00675 -0.0400009 0.0014000 145.1374 4.977681 0.1308174 0 0
4 83 0 0.1618 0.3912000 0.10125 3.005204 32.33435 1.100345 3.476130 -0.0759596 -0.0912144 0 0 1 0 0 0 0 0 0 0 0 0 0 0.2281006 0.0477016 0.1231570 0.1504770 9099.015 192.8014 0.0509721 -0.0110483 -0.0025010 -0.0024291 -0.0002083 0.0009565 0.00350 -0.0399990 0.0014000 170.9677 5.141475 0.1637940 0 0
4 84 1 0.1614 0.3926000 0.08942 3.253879 30.84224 1.179848 3.428885 0.0795026 -0.0472448 0 0 0 1 0 0 0 0 0 0 0 0 0 0.2262931 0.0469828 0.1206897 0.1512931 10052.484 195.4310 0.0996537 0.0135469 -0.0018075 -0.0007189 -0.0024673 0.0008161 -0.01183 -0.0400009 0.0014000 183.2611 5.210912 0.0694370 0 0
4 85 0 0.1610 0.3940000 0.08633 3.523421 32.81994 1.259432 3.491036 0.0795844 0.0621510 0 0 0 0 1 0 0 0 0 0 0 0 0 0.2247529 0.0472712 0.1173184 0.1521272 10674.928 197.2926 0.0600780 0.0094806 -0.0015402 0.0002884 -0.0033712 0.0008341 -0.00309 -0.0399990 0.0014000 193.1897 5.263672 0.0527606 0 0
4 86 1 0.1606 0.3954000 0.08758 4.015866 35.90437 1.390253 3.580859 0.1308208 0.0898230 0 0 0 0 0 1 0 0 0 0 0 0 0 0.2212693 0.0484563 0.1136364 0.1535163 11209.113 201.9297 0.0488293 0.0232313 -0.0034836 0.0011851 -0.0036821 0.0013891 0.00125 -0.0400009 0.0014000 203.0941 5.313669 0.0499969 0 0
4 87 0 0.1602 0.3968000 0.08100 4.201110 39.08497 1.435349 3.665738 0.0450958 0.0848787 0 0 0 0 0 0 1 0 0 0 0 0 0 0.2203245 0.0482494 0.1097353 0.1545687 11613.968 204.6115 0.0354814 0.0131934 -0.0009448 -0.0002069 -0.0039011 0.0010525 -0.00658 -0.0399990 0.0014000 221.2264 5.399187 0.0855174 0 0
library(ggplot2)
library(ggthemes)
ggplot(prison, aes(year, black, color=factor(state))) +    theme_solarized()   +    geom_line()

library(ggplot2)
library(ggthemes)
mean_st <- prison %>%  group_by( state ) %>%  summarise( mean_unem = mean( unem ) )
ggplot(mean_st, aes(state, mean_unem)) +    theme_solarized()   +    geom_point() 

library(ggplot2)
library(ggthemes)
mean_year <- prison %>%  group_by( year ) %>%  summarise( mean_unem = mean( unem ) )
ggplot(mean_year, aes(year, mean_unem)) +    theme_solarized()   +    geom_point()