class: center, middle, inverse, title-slide # Data Visualization ## Displaying tables ### Andrew Irwin,
a.irwin@dal.ca
### Math & Stats, Dalhousie University ### 2021-02-03 (updated: 2021-01-18) --- class: middle # Displaying tables * After we collect, reshape, and summarize data, we want to display it! * Rename and align columns * Format (bold, italic, colour) * Add column headings * Group rows * Add captions * Consistent goal: make the table easy to interpret --- class: middle ## Raw data .tiny[ ``` ## 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 ## Maserati Bora 15.0 8 301.0 335 3.54 3.570 14.60 0 1 5 8 ## Volvo 142E 21.4 4 121.0 109 4.11 2.780 18.60 1 1 4 2 ``` ] --- class: middle ## `kable` formatting ```r mtcars %>% kable() %>% kable_styling(full_width = FALSE, bootstrap_options = c("striped", "condensed")) ``` <table class="table table-striped table-condensed" style="width: auto !important; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> </th> <th style="text-align:right;"> mpg </th> <th style="text-align:right;"> cyl </th> <th style="text-align:right;"> disp </th> <th style="text-align:right;"> hp </th> <th style="text-align:right;"> drat </th> <th style="text-align:right;"> wt </th> <th style="text-align:right;"> qsec </th> <th style="text-align:right;"> vs </th> <th style="text-align:right;"> am </th> <th style="text-align:right;"> gear </th> <th style="text-align:right;"> carb </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Mazda RX4 </td> <td style="text-align:right;"> 21.0 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 160.0 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 3.90 </td> <td style="text-align:right;"> 2.620 </td> <td style="text-align:right;"> 16.46 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Mazda RX4 Wag </td> <td style="text-align:right;"> 21.0 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 160.0 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 3.90 </td> <td style="text-align:right;"> 2.875 </td> <td style="text-align:right;"> 17.02 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Datsun 710 </td> <td style="text-align:right;"> 22.8 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 108.0 </td> <td style="text-align:right;"> 93 </td> <td style="text-align:right;"> 3.85 </td> <td style="text-align:right;"> 2.320 </td> <td style="text-align:right;"> 18.61 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Hornet 4 Drive </td> <td style="text-align:right;"> 21.4 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 258.0 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 3.08 </td> <td style="text-align:right;"> 3.215 </td> <td style="text-align:right;"> 19.44 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Hornet Sportabout </td> <td style="text-align:right;"> 18.7 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 360.0 </td> <td style="text-align:right;"> 175 </td> <td style="text-align:right;"> 3.15 </td> <td style="text-align:right;"> 3.440 </td> <td style="text-align:right;"> 17.02 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Valiant </td> <td style="text-align:right;"> 18.1 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 225.0 </td> <td style="text-align:right;"> 105 </td> <td style="text-align:right;"> 2.76 </td> <td style="text-align:right;"> 3.460 </td> <td style="text-align:right;"> 20.22 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Duster 360 </td> <td style="text-align:right;"> 14.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 360.0 </td> <td style="text-align:right;"> 245 </td> <td style="text-align:right;"> 3.21 </td> <td style="text-align:right;"> 3.570 </td> <td style="text-align:right;"> 15.84 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Merc 240D </td> <td style="text-align:right;"> 24.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 146.7 </td> <td style="text-align:right;"> 62 </td> <td style="text-align:right;"> 3.69 </td> <td style="text-align:right;"> 3.190 </td> <td style="text-align:right;"> 20.00 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Merc 230 </td> <td style="text-align:right;"> 22.8 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 140.8 </td> <td style="text-align:right;"> 95 </td> <td style="text-align:right;"> 3.92 </td> <td style="text-align:right;"> 3.150 </td> <td style="text-align:right;"> 22.90 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Merc 280 </td> <td style="text-align:right;"> 19.2 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 167.6 </td> <td style="text-align:right;"> 123 </td> <td style="text-align:right;"> 3.92 </td> <td style="text-align:right;"> 3.440 </td> <td style="text-align:right;"> 18.30 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Merc 280C </td> <td style="text-align:right;"> 17.8 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 167.6 </td> <td style="text-align:right;"> 123 </td> <td style="text-align:right;"> 3.92 </td> <td style="text-align:right;"> 3.440 </td> <td style="text-align:right;"> 18.90 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SE </td> <td style="text-align:right;"> 16.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 275.8 </td> <td style="text-align:right;"> 180 </td> <td style="text-align:right;"> 3.07 </td> <td style="text-align:right;"> 4.070 </td> <td style="text-align:right;"> 17.40 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 3 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SL </td> <td style="text-align:right;"> 17.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 275.8 </td> <td style="text-align:right;"> 180 </td> <td style="text-align:right;"> 3.07 </td> <td style="text-align:right;"> 3.730 </td> <td style="text-align:right;"> 17.60 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 3 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SLC </td> <td style="text-align:right;"> 15.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 275.8 </td> <td style="text-align:right;"> 180 </td> <td style="text-align:right;"> 3.07 </td> <td style="text-align:right;"> 3.780 </td> <td style="text-align:right;"> 18.00 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 3 </td> </tr> <tr> <td style="text-align:left;"> Cadillac Fleetwood </td> <td style="text-align:right;"> 10.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 472.0 </td> <td style="text-align:right;"> 205 </td> <td style="text-align:right;"> 2.93 </td> <td style="text-align:right;"> 5.250 </td> <td style="text-align:right;"> 17.98 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Lincoln Continental </td> <td style="text-align:right;"> 10.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 460.0 </td> <td style="text-align:right;"> 215 </td> <td style="text-align:right;"> 3.00 </td> <td style="text-align:right;"> 5.424 </td> <td style="text-align:right;"> 17.82 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Chrysler Imperial </td> <td style="text-align:right;"> 14.7 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 440.0 </td> <td style="text-align:right;"> 230 </td> <td style="text-align:right;"> 3.23 </td> <td style="text-align:right;"> 5.345 </td> <td style="text-align:right;"> 17.42 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Fiat 128 </td> <td style="text-align:right;"> 32.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 78.7 </td> <td style="text-align:right;"> 66 </td> <td style="text-align:right;"> 4.08 </td> <td style="text-align:right;"> 2.200 </td> <td style="text-align:right;"> 19.47 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Honda Civic </td> <td style="text-align:right;"> 30.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 75.7 </td> <td style="text-align:right;"> 52 </td> <td style="text-align:right;"> 4.93 </td> <td style="text-align:right;"> 1.615 </td> <td style="text-align:right;"> 18.52 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Toyota Corolla </td> <td style="text-align:right;"> 33.9 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 71.1 </td> <td style="text-align:right;"> 65 </td> <td style="text-align:right;"> 4.22 </td> <td style="text-align:right;"> 1.835 </td> <td style="text-align:right;"> 19.90 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Toyota Corona </td> <td style="text-align:right;"> 21.5 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 120.1 </td> <td style="text-align:right;"> 97 </td> <td style="text-align:right;"> 3.70 </td> <td style="text-align:right;"> 2.465 </td> <td style="text-align:right;"> 20.01 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Dodge Challenger </td> <td style="text-align:right;"> 15.5 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 318.0 </td> <td style="text-align:right;"> 150 </td> <td style="text-align:right;"> 2.76 </td> <td style="text-align:right;"> 3.520 </td> <td style="text-align:right;"> 16.87 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> AMC Javelin </td> <td style="text-align:right;"> 15.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 304.0 </td> <td style="text-align:right;"> 150 </td> <td style="text-align:right;"> 3.15 </td> <td style="text-align:right;"> 3.435 </td> <td style="text-align:right;"> 17.30 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Camaro Z28 </td> <td style="text-align:right;"> 13.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 350.0 </td> <td style="text-align:right;"> 245 </td> <td style="text-align:right;"> 3.73 </td> <td style="text-align:right;"> 3.840 </td> <td style="text-align:right;"> 15.41 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Pontiac Firebird </td> <td style="text-align:right;"> 19.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 400.0 </td> <td style="text-align:right;"> 175 </td> <td style="text-align:right;"> 3.08 </td> <td style="text-align:right;"> 3.845 </td> <td style="text-align:right;"> 17.05 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Fiat X1-9 </td> <td style="text-align:right;"> 27.3 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 79.0 </td> <td style="text-align:right;"> 66 </td> <td style="text-align:right;"> 4.08 </td> <td style="text-align:right;"> 1.935 </td> <td style="text-align:right;"> 18.90 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Porsche 914-2 </td> <td style="text-align:right;"> 26.0 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 120.3 </td> <td style="text-align:right;"> 91 </td> <td style="text-align:right;"> 4.43 </td> <td style="text-align:right;"> 2.140 </td> <td style="text-align:right;"> 16.70 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Lotus Europa </td> <td style="text-align:right;"> 30.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 95.1 </td> <td style="text-align:right;"> 113 </td> <td style="text-align:right;"> 3.77 </td> <td style="text-align:right;"> 1.513 </td> <td style="text-align:right;"> 16.90 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Ford Pantera L </td> <td style="text-align:right;"> 15.8 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 351.0 </td> <td style="text-align:right;"> 264 </td> <td style="text-align:right;"> 4.22 </td> <td style="text-align:right;"> 3.170 </td> <td style="text-align:right;"> 14.50 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Ferrari Dino </td> <td style="text-align:right;"> 19.7 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 145.0 </td> <td style="text-align:right;"> 175 </td> <td style="text-align:right;"> 3.62 </td> <td style="text-align:right;"> 2.770 </td> <td style="text-align:right;"> 15.50 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 6 </td> </tr> <tr> <td style="text-align:left;"> Maserati Bora </td> <td style="text-align:right;"> 15.0 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 301.0 </td> <td style="text-align:right;"> 335 </td> <td style="text-align:right;"> 3.54 </td> <td style="text-align:right;"> 3.570 </td> <td style="text-align:right;"> 14.60 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 8 </td> </tr> <tr> <td style="text-align:left;"> Volvo 142E </td> <td style="text-align:right;"> 21.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 121.0 </td> <td style="text-align:right;"> 109 </td> <td style="text-align:right;"> 4.11 </td> <td style="text-align:right;"> 2.780 </td> <td style="text-align:right;"> 18.60 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 2 </td> </tr> </tbody> </table> --- class: middle ## Scrolling to show big tables ```r mtcars %>% kable() %>% kable_styling() %>% scroll_box() ``` <div style="border: 1px solid #ddd; padding: 5px; "><table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> </th> <th style="text-align:right;"> mpg </th> <th style="text-align:right;"> cyl </th> <th style="text-align:right;"> disp </th> <th style="text-align:right;"> hp </th> <th style="text-align:right;"> drat </th> <th style="text-align:right;"> wt </th> <th style="text-align:right;"> qsec </th> <th style="text-align:right;"> vs </th> <th style="text-align:right;"> am </th> <th style="text-align:right;"> gear </th> <th style="text-align:right;"> carb </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Mazda RX4 </td> <td style="text-align:right;"> 21.0 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 160.0 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 3.90 </td> <td style="text-align:right;"> 2.620 </td> <td style="text-align:right;"> 16.46 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Mazda RX4 Wag </td> <td style="text-align:right;"> 21.0 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 160.0 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 3.90 </td> <td style="text-align:right;"> 2.875 </td> <td style="text-align:right;"> 17.02 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Datsun 710 </td> <td style="text-align:right;"> 22.8 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 108.0 </td> <td style="text-align:right;"> 93 </td> <td style="text-align:right;"> 3.85 </td> <td style="text-align:right;"> 2.320 </td> <td style="text-align:right;"> 18.61 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Hornet 4 Drive </td> <td style="text-align:right;"> 21.4 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 258.0 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 3.08 </td> <td style="text-align:right;"> 3.215 </td> <td style="text-align:right;"> 19.44 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Hornet Sportabout </td> <td style="text-align:right;"> 18.7 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 360.0 </td> <td style="text-align:right;"> 175 </td> <td style="text-align:right;"> 3.15 </td> <td style="text-align:right;"> 3.440 </td> <td style="text-align:right;"> 17.02 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Valiant </td> <td style="text-align:right;"> 18.1 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 225.0 </td> <td style="text-align:right;"> 105 </td> <td style="text-align:right;"> 2.76 </td> <td style="text-align:right;"> 3.460 </td> <td style="text-align:right;"> 20.22 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Duster 360 </td> <td style="text-align:right;"> 14.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 360.0 </td> <td style="text-align:right;"> 245 </td> <td style="text-align:right;"> 3.21 </td> <td style="text-align:right;"> 3.570 </td> <td style="text-align:right;"> 15.84 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Merc 240D </td> <td style="text-align:right;"> 24.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 146.7 </td> <td style="text-align:right;"> 62 </td> <td style="text-align:right;"> 3.69 </td> <td style="text-align:right;"> 3.190 </td> <td style="text-align:right;"> 20.00 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Merc 230 </td> <td style="text-align:right;"> 22.8 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 140.8 </td> <td style="text-align:right;"> 95 </td> <td style="text-align:right;"> 3.92 </td> <td style="text-align:right;"> 3.150 </td> <td style="text-align:right;"> 22.90 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Merc 280 </td> <td style="text-align:right;"> 19.2 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 167.6 </td> <td style="text-align:right;"> 123 </td> <td style="text-align:right;"> 3.92 </td> <td style="text-align:right;"> 3.440 </td> <td style="text-align:right;"> 18.30 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Merc 280C </td> <td style="text-align:right;"> 17.8 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 167.6 </td> <td style="text-align:right;"> 123 </td> <td style="text-align:right;"> 3.92 </td> <td style="text-align:right;"> 3.440 </td> <td style="text-align:right;"> 18.90 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SE </td> <td style="text-align:right;"> 16.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 275.8 </td> <td style="text-align:right;"> 180 </td> <td style="text-align:right;"> 3.07 </td> <td style="text-align:right;"> 4.070 </td> <td style="text-align:right;"> 17.40 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 3 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SL </td> <td style="text-align:right;"> 17.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 275.8 </td> <td style="text-align:right;"> 180 </td> <td style="text-align:right;"> 3.07 </td> <td style="text-align:right;"> 3.730 </td> <td style="text-align:right;"> 17.60 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 3 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SLC </td> <td style="text-align:right;"> 15.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 275.8 </td> <td style="text-align:right;"> 180 </td> <td style="text-align:right;"> 3.07 </td> <td style="text-align:right;"> 3.780 </td> <td style="text-align:right;"> 18.00 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 3 </td> </tr> <tr> <td style="text-align:left;"> Cadillac Fleetwood </td> <td style="text-align:right;"> 10.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 472.0 </td> <td style="text-align:right;"> 205 </td> <td style="text-align:right;"> 2.93 </td> <td style="text-align:right;"> 5.250 </td> <td style="text-align:right;"> 17.98 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Lincoln Continental </td> <td style="text-align:right;"> 10.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 460.0 </td> <td style="text-align:right;"> 215 </td> <td style="text-align:right;"> 3.00 </td> <td style="text-align:right;"> 5.424 </td> <td style="text-align:right;"> 17.82 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Chrysler Imperial </td> <td style="text-align:right;"> 14.7 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 440.0 </td> <td style="text-align:right;"> 230 </td> <td style="text-align:right;"> 3.23 </td> <td style="text-align:right;"> 5.345 </td> <td style="text-align:right;"> 17.42 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Fiat 128 </td> <td style="text-align:right;"> 32.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 78.7 </td> <td style="text-align:right;"> 66 </td> <td style="text-align:right;"> 4.08 </td> <td style="text-align:right;"> 2.200 </td> <td style="text-align:right;"> 19.47 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Honda Civic </td> <td style="text-align:right;"> 30.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 75.7 </td> <td style="text-align:right;"> 52 </td> <td style="text-align:right;"> 4.93 </td> <td style="text-align:right;"> 1.615 </td> <td style="text-align:right;"> 18.52 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Toyota Corolla </td> <td style="text-align:right;"> 33.9 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 71.1 </td> <td style="text-align:right;"> 65 </td> <td style="text-align:right;"> 4.22 </td> <td style="text-align:right;"> 1.835 </td> <td style="text-align:right;"> 19.90 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Toyota Corona </td> <td style="text-align:right;"> 21.5 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 120.1 </td> <td style="text-align:right;"> 97 </td> <td style="text-align:right;"> 3.70 </td> <td style="text-align:right;"> 2.465 </td> <td style="text-align:right;"> 20.01 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Dodge Challenger </td> <td style="text-align:right;"> 15.5 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 318.0 </td> <td style="text-align:right;"> 150 </td> <td style="text-align:right;"> 2.76 </td> <td style="text-align:right;"> 3.520 </td> <td style="text-align:right;"> 16.87 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> AMC Javelin </td> <td style="text-align:right;"> 15.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 304.0 </td> <td style="text-align:right;"> 150 </td> <td style="text-align:right;"> 3.15 </td> <td style="text-align:right;"> 3.435 </td> <td style="text-align:right;"> 17.30 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Camaro Z28 </td> <td style="text-align:right;"> 13.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 350.0 </td> <td style="text-align:right;"> 245 </td> <td style="text-align:right;"> 3.73 </td> <td style="text-align:right;"> 3.840 </td> <td style="text-align:right;"> 15.41 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Pontiac Firebird </td> <td style="text-align:right;"> 19.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 400.0 </td> <td style="text-align:right;"> 175 </td> <td style="text-align:right;"> 3.08 </td> <td style="text-align:right;"> 3.845 </td> <td style="text-align:right;"> 17.05 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Fiat X1-9 </td> <td style="text-align:right;"> 27.3 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 79.0 </td> <td style="text-align:right;"> 66 </td> <td style="text-align:right;"> 4.08 </td> <td style="text-align:right;"> 1.935 </td> <td style="text-align:right;"> 18.90 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Porsche 914-2 </td> <td style="text-align:right;"> 26.0 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 120.3 </td> <td style="text-align:right;"> 91 </td> <td style="text-align:right;"> 4.43 </td> <td style="text-align:right;"> 2.140 </td> <td style="text-align:right;"> 16.70 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Lotus Europa </td> <td style="text-align:right;"> 30.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 95.1 </td> <td style="text-align:right;"> 113 </td> <td style="text-align:right;"> 3.77 </td> <td style="text-align:right;"> 1.513 </td> <td style="text-align:right;"> 16.90 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> Ford Pantera L </td> <td style="text-align:right;"> 15.8 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 351.0 </td> <td style="text-align:right;"> 264 </td> <td style="text-align:right;"> 4.22 </td> <td style="text-align:right;"> 3.170 </td> <td style="text-align:right;"> 14.50 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 4 </td> </tr> <tr> <td style="text-align:left;"> Ferrari Dino </td> <td style="text-align:right;"> 19.7 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 145.0 </td> <td style="text-align:right;"> 175 </td> <td style="text-align:right;"> 3.62 </td> <td style="text-align:right;"> 2.770 </td> <td style="text-align:right;"> 15.50 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 6 </td> </tr> <tr> <td style="text-align:left;"> Maserati Bora </td> <td style="text-align:right;"> 15.0 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 301.0 </td> <td style="text-align:right;"> 335 </td> <td style="text-align:right;"> 3.54 </td> <td style="text-align:right;"> 3.570 </td> <td style="text-align:right;"> 14.60 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 8 </td> </tr> <tr> <td style="text-align:left;"> Volvo 142E </td> <td style="text-align:right;"> 21.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 121.0 </td> <td style="text-align:right;"> 109 </td> <td style="text-align:right;"> 4.11 </td> <td style="text-align:right;"> 2.780 </td> <td style="text-align:right;"> 18.60 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 2 </td> </tr> </tbody> </table></div> --- class: middle ## Paged data to show big tables ```r mtcars %>% rmarkdown::paged_table() ``` <div data-pagedtable="false"> <script data-pagedtable-source type="application/json"> {"columns":[{"label":[""],"name":["_rn_"],"type":[""],"align":["left"]},{"label":["mpg"],"name":[1],"type":["dbl"],"align":["right"]},{"label":["cyl"],"name":[2],"type":["dbl"],"align":["right"]},{"label":["disp"],"name":[3],"type":["dbl"],"align":["right"]},{"label":["hp"],"name":[4],"type":["dbl"],"align":["right"]},{"label":["drat"],"name":[5],"type":["dbl"],"align":["right"]},{"label":["wt"],"name":[6],"type":["dbl"],"align":["right"]},{"label":["qsec"],"name":[7],"type":["dbl"],"align":["right"]},{"label":["vs"],"name":[8],"type":["dbl"],"align":["right"]},{"label":["am"],"name":[9],"type":["dbl"],"align":["right"]},{"label":["gear"],"name":[10],"type":["dbl"],"align":["right"]},{"label":["carb"],"name":[11],"type":["dbl"],"align":["right"]}],"data":[{"1":"21.0","2":"6","3":"160.0","4":"110","5":"3.90","6":"2.620","7":"16.46","8":"0","9":"1","10":"4","11":"4","_rn_":"Mazda RX4"},{"1":"21.0","2":"6","3":"160.0","4":"110","5":"3.90","6":"2.875","7":"17.02","8":"0","9":"1","10":"4","11":"4","_rn_":"Mazda RX4 Wag"},{"1":"22.8","2":"4","3":"108.0","4":"93","5":"3.85","6":"2.320","7":"18.61","8":"1","9":"1","10":"4","11":"1","_rn_":"Datsun 710"},{"1":"21.4","2":"6","3":"258.0","4":"110","5":"3.08","6":"3.215","7":"19.44","8":"1","9":"0","10":"3","11":"1","_rn_":"Hornet 4 Drive"},{"1":"18.7","2":"8","3":"360.0","4":"175","5":"3.15","6":"3.440","7":"17.02","8":"0","9":"0","10":"3","11":"2","_rn_":"Hornet Sportabout"},{"1":"18.1","2":"6","3":"225.0","4":"105","5":"2.76","6":"3.460","7":"20.22","8":"1","9":"0","10":"3","11":"1","_rn_":"Valiant"},{"1":"14.3","2":"8","3":"360.0","4":"245","5":"3.21","6":"3.570","7":"15.84","8":"0","9":"0","10":"3","11":"4","_rn_":"Duster 360"},{"1":"24.4","2":"4","3":"146.7","4":"62","5":"3.69","6":"3.190","7":"20.00","8":"1","9":"0","10":"4","11":"2","_rn_":"Merc 240D"},{"1":"22.8","2":"4","3":"140.8","4":"95","5":"3.92","6":"3.150","7":"22.90","8":"1","9":"0","10":"4","11":"2","_rn_":"Merc 230"},{"1":"19.2","2":"6","3":"167.6","4":"123","5":"3.92","6":"3.440","7":"18.30","8":"1","9":"0","10":"4","11":"4","_rn_":"Merc 280"},{"1":"17.8","2":"6","3":"167.6","4":"123","5":"3.92","6":"3.440","7":"18.90","8":"1","9":"0","10":"4","11":"4","_rn_":"Merc 280C"},{"1":"16.4","2":"8","3":"275.8","4":"180","5":"3.07","6":"4.070","7":"17.40","8":"0","9":"0","10":"3","11":"3","_rn_":"Merc 450SE"},{"1":"17.3","2":"8","3":"275.8","4":"180","5":"3.07","6":"3.730","7":"17.60","8":"0","9":"0","10":"3","11":"3","_rn_":"Merc 450SL"},{"1":"15.2","2":"8","3":"275.8","4":"180","5":"3.07","6":"3.780","7":"18.00","8":"0","9":"0","10":"3","11":"3","_rn_":"Merc 450SLC"},{"1":"10.4","2":"8","3":"472.0","4":"205","5":"2.93","6":"5.250","7":"17.98","8":"0","9":"0","10":"3","11":"4","_rn_":"Cadillac Fleetwood"},{"1":"10.4","2":"8","3":"460.0","4":"215","5":"3.00","6":"5.424","7":"17.82","8":"0","9":"0","10":"3","11":"4","_rn_":"Lincoln Continental"},{"1":"14.7","2":"8","3":"440.0","4":"230","5":"3.23","6":"5.345","7":"17.42","8":"0","9":"0","10":"3","11":"4","_rn_":"Chrysler Imperial"},{"1":"32.4","2":"4","3":"78.7","4":"66","5":"4.08","6":"2.200","7":"19.47","8":"1","9":"1","10":"4","11":"1","_rn_":"Fiat 128"},{"1":"30.4","2":"4","3":"75.7","4":"52","5":"4.93","6":"1.615","7":"18.52","8":"1","9":"1","10":"4","11":"2","_rn_":"Honda Civic"},{"1":"33.9","2":"4","3":"71.1","4":"65","5":"4.22","6":"1.835","7":"19.90","8":"1","9":"1","10":"4","11":"1","_rn_":"Toyota Corolla"},{"1":"21.5","2":"4","3":"120.1","4":"97","5":"3.70","6":"2.465","7":"20.01","8":"1","9":"0","10":"3","11":"1","_rn_":"Toyota Corona"},{"1":"15.5","2":"8","3":"318.0","4":"150","5":"2.76","6":"3.520","7":"16.87","8":"0","9":"0","10":"3","11":"2","_rn_":"Dodge Challenger"},{"1":"15.2","2":"8","3":"304.0","4":"150","5":"3.15","6":"3.435","7":"17.30","8":"0","9":"0","10":"3","11":"2","_rn_":"AMC Javelin"},{"1":"13.3","2":"8","3":"350.0","4":"245","5":"3.73","6":"3.840","7":"15.41","8":"0","9":"0","10":"3","11":"4","_rn_":"Camaro Z28"},{"1":"19.2","2":"8","3":"400.0","4":"175","5":"3.08","6":"3.845","7":"17.05","8":"0","9":"0","10":"3","11":"2","_rn_":"Pontiac Firebird"},{"1":"27.3","2":"4","3":"79.0","4":"66","5":"4.08","6":"1.935","7":"18.90","8":"1","9":"1","10":"4","11":"1","_rn_":"Fiat X1-9"},{"1":"26.0","2":"4","3":"120.3","4":"91","5":"4.43","6":"2.140","7":"16.70","8":"0","9":"1","10":"5","11":"2","_rn_":"Porsche 914-2"},{"1":"30.4","2":"4","3":"95.1","4":"113","5":"3.77","6":"1.513","7":"16.90","8":"1","9":"1","10":"5","11":"2","_rn_":"Lotus Europa"},{"1":"15.8","2":"8","3":"351.0","4":"264","5":"4.22","6":"3.170","7":"14.50","8":"0","9":"1","10":"5","11":"4","_rn_":"Ford Pantera L"},{"1":"19.7","2":"6","3":"145.0","4":"175","5":"3.62","6":"2.770","7":"15.50","8":"0","9":"1","10":"5","11":"6","_rn_":"Ferrari Dino"},{"1":"15.0","2":"8","3":"301.0","4":"335","5":"3.54","6":"3.570","7":"14.60","8":"0","9":"1","10":"5","11":"8","_rn_":"Maserati Bora"},{"1":"21.4","2":"4","3":"121.0","4":"109","5":"4.11","6":"2.780","7":"18.60","8":"1","9":"1","10":"4","11":"2","_rn_":"Volvo 142E"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}} </script> </div> --- class: middle ## Changing column headings ```r mtcars %>% as_tibble(rownames = "make_model") %>% select(make_model, mpg, cyl, wt) %>% kable(col.names = c("Make & Model", "Miles per gallon", "Cylinders", "Weight (1000 lbs)")) %>% kable_styling(full_width = FALSE, bootstrap_options = "striped") ``` <table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Make & Model </th> <th style="text-align:right;"> Miles per gallon </th> <th style="text-align:right;"> Cylinders </th> <th style="text-align:right;"> Weight (1000 lbs) </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Mazda RX4 </td> <td style="text-align:right;"> 21.0 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 2.620 </td> </tr> <tr> <td style="text-align:left;"> Mazda RX4 Wag </td> <td style="text-align:right;"> 21.0 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 2.875 </td> </tr> <tr> <td style="text-align:left;"> Datsun 710 </td> <td style="text-align:right;"> 22.8 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 2.320 </td> </tr> <tr> <td style="text-align:left;"> Hornet 4 Drive </td> <td style="text-align:right;"> 21.4 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 3.215 </td> </tr> <tr> <td style="text-align:left;"> Hornet Sportabout </td> <td style="text-align:right;"> 18.7 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 3.440 </td> </tr> <tr> <td style="text-align:left;"> Valiant </td> <td style="text-align:right;"> 18.1 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 3.460 </td> </tr> <tr> <td style="text-align:left;"> Duster 360 </td> <td style="text-align:right;"> 14.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 3.570 </td> </tr> <tr> <td style="text-align:left;"> Merc 240D </td> <td style="text-align:right;"> 24.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 3.190 </td> </tr> <tr> <td style="text-align:left;"> Merc 230 </td> <td style="text-align:right;"> 22.8 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 3.150 </td> </tr> <tr> <td style="text-align:left;"> Merc 280 </td> <td style="text-align:right;"> 19.2 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 3.440 </td> </tr> <tr> <td style="text-align:left;"> Merc 280C </td> <td style="text-align:right;"> 17.8 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 3.440 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SE </td> <td style="text-align:right;"> 16.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 4.070 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SL </td> <td style="text-align:right;"> 17.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 3.730 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SLC </td> <td style="text-align:right;"> 15.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 3.780 </td> </tr> <tr> <td style="text-align:left;"> Cadillac Fleetwood </td> <td style="text-align:right;"> 10.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 5.250 </td> </tr> <tr> <td style="text-align:left;"> Lincoln Continental </td> <td style="text-align:right;"> 10.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 5.424 </td> </tr> <tr> <td style="text-align:left;"> Chrysler Imperial </td> <td style="text-align:right;"> 14.7 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 5.345 </td> </tr> <tr> <td style="text-align:left;"> Fiat 128 </td> <td style="text-align:right;"> 32.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 2.200 </td> </tr> <tr> <td style="text-align:left;"> Honda Civic </td> <td style="text-align:right;"> 30.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 1.615 </td> </tr> <tr> <td style="text-align:left;"> Toyota Corolla </td> <td style="text-align:right;"> 33.9 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 1.835 </td> </tr> <tr> <td style="text-align:left;"> Toyota Corona </td> <td style="text-align:right;"> 21.5 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 2.465 </td> </tr> <tr> <td style="text-align:left;"> Dodge Challenger </td> <td style="text-align:right;"> 15.5 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 3.520 </td> </tr> <tr> <td style="text-align:left;"> AMC Javelin </td> <td style="text-align:right;"> 15.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 3.435 </td> </tr> <tr> <td style="text-align:left;"> Camaro Z28 </td> <td style="text-align:right;"> 13.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 3.840 </td> </tr> <tr> <td style="text-align:left;"> Pontiac Firebird </td> <td style="text-align:right;"> 19.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 3.845 </td> </tr> <tr> <td style="text-align:left;"> Fiat X1-9 </td> <td style="text-align:right;"> 27.3 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 1.935 </td> </tr> <tr> <td style="text-align:left;"> Porsche 914-2 </td> <td style="text-align:right;"> 26.0 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 2.140 </td> </tr> <tr> <td style="text-align:left;"> Lotus Europa </td> <td style="text-align:right;"> 30.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 1.513 </td> </tr> <tr> <td style="text-align:left;"> Ford Pantera L </td> <td style="text-align:right;"> 15.8 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 3.170 </td> </tr> <tr> <td style="text-align:left;"> Ferrari Dino </td> <td style="text-align:right;"> 19.7 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 2.770 </td> </tr> <tr> <td style="text-align:left;"> Maserati Bora </td> <td style="text-align:right;"> 15.0 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 3.570 </td> </tr> <tr> <td style="text-align:left;"> Volvo 142E </td> <td style="text-align:right;"> 21.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 2.780 </td> </tr> </tbody> </table> --- class: middle ## Formatting rows & columns ```r mtcars %>% as_tibble(rownames = "make_model") %>% select(make_model, mpg, cyl, wt) %>% kable(col.names = c("Make & Model", "Miles per gallon", "Cylinders", "Weight (1000 lbs)"), align = "lccr", digits = 1) %>% column_spec(1, bold = TRUE) %>% column_spec(3, color = "blue") %>% row_spec(2, italic = TRUE) %>% kable_styling(full_width = FALSE, font_size=24, bootstrap_options = "striped") ``` <table class="table table-striped" style="font-size: 24px; width: auto !important; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Make & Model </th> <th style="text-align:center;"> Miles per gallon </th> <th style="text-align:center;"> Cylinders </th> <th style="text-align:right;"> Weight (1000 lbs) </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;font-weight: bold;"> Mazda RX4 </td> <td style="text-align:center;"> 21.0 </td> <td style="text-align:center;color: blue !important;"> 6 </td> <td style="text-align:right;"> 2.6 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;font-style: italic;"> Mazda RX4 Wag </td> <td style="text-align:center;font-style: italic;"> 21.0 </td> <td style="text-align:center;color: blue !important;font-style: italic;"> 6 </td> <td style="text-align:right;font-style: italic;"> 2.9 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Datsun 710 </td> <td style="text-align:center;"> 22.8 </td> <td style="text-align:center;color: blue !important;"> 4 </td> <td style="text-align:right;"> 2.3 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Hornet 4 Drive </td> <td style="text-align:center;"> 21.4 </td> <td style="text-align:center;color: blue !important;"> 6 </td> <td style="text-align:right;"> 3.2 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Hornet Sportabout </td> <td style="text-align:center;"> 18.7 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 3.4 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Valiant </td> <td style="text-align:center;"> 18.1 </td> <td style="text-align:center;color: blue !important;"> 6 </td> <td style="text-align:right;"> 3.5 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Duster 360 </td> <td style="text-align:center;"> 14.3 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 3.6 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Merc 240D </td> <td style="text-align:center;"> 24.4 </td> <td style="text-align:center;color: blue !important;"> 4 </td> <td style="text-align:right;"> 3.2 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Merc 230 </td> <td style="text-align:center;"> 22.8 </td> <td style="text-align:center;color: blue !important;"> 4 </td> <td style="text-align:right;"> 3.1 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Merc 280 </td> <td style="text-align:center;"> 19.2 </td> <td style="text-align:center;color: blue !important;"> 6 </td> <td style="text-align:right;"> 3.4 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Merc 280C </td> <td style="text-align:center;"> 17.8 </td> <td style="text-align:center;color: blue !important;"> 6 </td> <td style="text-align:right;"> 3.4 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Merc 450SE </td> <td style="text-align:center;"> 16.4 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 4.1 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Merc 450SL </td> <td style="text-align:center;"> 17.3 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 3.7 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Merc 450SLC </td> <td style="text-align:center;"> 15.2 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 3.8 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Cadillac Fleetwood </td> <td style="text-align:center;"> 10.4 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 5.2 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Lincoln Continental </td> <td style="text-align:center;"> 10.4 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 5.4 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Chrysler Imperial </td> <td style="text-align:center;"> 14.7 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 5.3 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Fiat 128 </td> <td style="text-align:center;"> 32.4 </td> <td style="text-align:center;color: blue !important;"> 4 </td> <td style="text-align:right;"> 2.2 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Honda Civic </td> <td style="text-align:center;"> 30.4 </td> <td style="text-align:center;color: blue !important;"> 4 </td> <td style="text-align:right;"> 1.6 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Toyota Corolla </td> <td style="text-align:center;"> 33.9 </td> <td style="text-align:center;color: blue !important;"> 4 </td> <td style="text-align:right;"> 1.8 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Toyota Corona </td> <td style="text-align:center;"> 21.5 </td> <td style="text-align:center;color: blue !important;"> 4 </td> <td style="text-align:right;"> 2.5 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Dodge Challenger </td> <td style="text-align:center;"> 15.5 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 3.5 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> AMC Javelin </td> <td style="text-align:center;"> 15.2 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 3.4 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Camaro Z28 </td> <td style="text-align:center;"> 13.3 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 3.8 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Pontiac Firebird </td> <td style="text-align:center;"> 19.2 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 3.8 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Fiat X1-9 </td> <td style="text-align:center;"> 27.3 </td> <td style="text-align:center;color: blue !important;"> 4 </td> <td style="text-align:right;"> 1.9 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Porsche 914-2 </td> <td style="text-align:center;"> 26.0 </td> <td style="text-align:center;color: blue !important;"> 4 </td> <td style="text-align:right;"> 2.1 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Lotus Europa </td> <td style="text-align:center;"> 30.4 </td> <td style="text-align:center;color: blue !important;"> 4 </td> <td style="text-align:right;"> 1.5 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Ford Pantera L </td> <td style="text-align:center;"> 15.8 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 3.2 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Ferrari Dino </td> <td style="text-align:center;"> 19.7 </td> <td style="text-align:center;color: blue !important;"> 6 </td> <td style="text-align:right;"> 2.8 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Maserati Bora </td> <td style="text-align:center;"> 15.0 </td> <td style="text-align:center;color: blue !important;"> 8 </td> <td style="text-align:right;"> 3.6 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;"> Volvo 142E </td> <td style="text-align:center;"> 21.4 </td> <td style="text-align:center;color: blue !important;"> 4 </td> <td style="text-align:right;"> 2.8 </td> </tr> </tbody> </table> --- class: middle ## Headers spanning multiple columns ```r mtcars %>% select(mpg, cyl, hp, wt) %>% kable() %>% add_header_above(c(" " = 1, "Group A" = 2, "Group B" = 2)) %>% kable_styling(full_width = FALSE, bootstrap_options = "striped") ``` <table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="empty-cells: hide;border-bottom:hidden;" colspan="1"></th> <th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">Group A</div></th> <th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="2"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">Group B</div></th> </tr> <tr> <th style="text-align:left;"> </th> <th style="text-align:right;"> mpg </th> <th style="text-align:right;"> cyl </th> <th style="text-align:right;"> hp </th> <th style="text-align:right;"> wt </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Mazda RX4 </td> <td style="text-align:right;"> 21.0 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 2.620 </td> </tr> <tr> <td style="text-align:left;"> Mazda RX4 Wag </td> <td style="text-align:right;"> 21.0 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 2.875 </td> </tr> <tr> <td style="text-align:left;"> Datsun 710 </td> <td style="text-align:right;"> 22.8 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 93 </td> <td style="text-align:right;"> 2.320 </td> </tr> <tr> <td style="text-align:left;"> Hornet 4 Drive </td> <td style="text-align:right;"> 21.4 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 3.215 </td> </tr> <tr> <td style="text-align:left;"> Hornet Sportabout </td> <td style="text-align:right;"> 18.7 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 175 </td> <td style="text-align:right;"> 3.440 </td> </tr> <tr> <td style="text-align:left;"> Valiant </td> <td style="text-align:right;"> 18.1 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 105 </td> <td style="text-align:right;"> 3.460 </td> </tr> <tr> <td style="text-align:left;"> Duster 360 </td> <td style="text-align:right;"> 14.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 245 </td> <td style="text-align:right;"> 3.570 </td> </tr> <tr> <td style="text-align:left;"> Merc 240D </td> <td style="text-align:right;"> 24.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 62 </td> <td style="text-align:right;"> 3.190 </td> </tr> <tr> <td style="text-align:left;"> Merc 230 </td> <td style="text-align:right;"> 22.8 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 95 </td> <td style="text-align:right;"> 3.150 </td> </tr> <tr> <td style="text-align:left;"> Merc 280 </td> <td style="text-align:right;"> 19.2 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 123 </td> <td style="text-align:right;"> 3.440 </td> </tr> <tr> <td style="text-align:left;"> Merc 280C </td> <td style="text-align:right;"> 17.8 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 123 </td> <td style="text-align:right;"> 3.440 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SE </td> <td style="text-align:right;"> 16.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 180 </td> <td style="text-align:right;"> 4.070 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SL </td> <td style="text-align:right;"> 17.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 180 </td> <td style="text-align:right;"> 3.730 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SLC </td> <td style="text-align:right;"> 15.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 180 </td> <td style="text-align:right;"> 3.780 </td> </tr> <tr> <td style="text-align:left;"> Cadillac Fleetwood </td> <td style="text-align:right;"> 10.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 205 </td> <td style="text-align:right;"> 5.250 </td> </tr> <tr> <td style="text-align:left;"> Lincoln Continental </td> <td style="text-align:right;"> 10.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 215 </td> <td style="text-align:right;"> 5.424 </td> </tr> <tr> <td style="text-align:left;"> Chrysler Imperial </td> <td style="text-align:right;"> 14.7 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 230 </td> <td style="text-align:right;"> 5.345 </td> </tr> <tr> <td style="text-align:left;"> Fiat 128 </td> <td style="text-align:right;"> 32.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 66 </td> <td style="text-align:right;"> 2.200 </td> </tr> <tr> <td style="text-align:left;"> Honda Civic </td> <td style="text-align:right;"> 30.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 52 </td> <td style="text-align:right;"> 1.615 </td> </tr> <tr> <td style="text-align:left;"> Toyota Corolla </td> <td style="text-align:right;"> 33.9 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 65 </td> <td style="text-align:right;"> 1.835 </td> </tr> <tr> <td style="text-align:left;"> Toyota Corona </td> <td style="text-align:right;"> 21.5 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 97 </td> <td style="text-align:right;"> 2.465 </td> </tr> <tr> <td style="text-align:left;"> Dodge Challenger </td> <td style="text-align:right;"> 15.5 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 150 </td> <td style="text-align:right;"> 3.520 </td> </tr> <tr> <td style="text-align:left;"> AMC Javelin </td> <td style="text-align:right;"> 15.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 150 </td> <td style="text-align:right;"> 3.435 </td> </tr> <tr> <td style="text-align:left;"> Camaro Z28 </td> <td style="text-align:right;"> 13.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 245 </td> <td style="text-align:right;"> 3.840 </td> </tr> <tr> <td style="text-align:left;"> Pontiac Firebird </td> <td style="text-align:right;"> 19.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 175 </td> <td style="text-align:right;"> 3.845 </td> </tr> <tr> <td style="text-align:left;"> Fiat X1-9 </td> <td style="text-align:right;"> 27.3 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 66 </td> <td style="text-align:right;"> 1.935 </td> </tr> <tr> <td style="text-align:left;"> Porsche 914-2 </td> <td style="text-align:right;"> 26.0 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 91 </td> <td style="text-align:right;"> 2.140 </td> </tr> <tr> <td style="text-align:left;"> Lotus Europa </td> <td style="text-align:right;"> 30.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 113 </td> <td style="text-align:right;"> 1.513 </td> </tr> <tr> <td style="text-align:left;"> Ford Pantera L </td> <td style="text-align:right;"> 15.8 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 264 </td> <td style="text-align:right;"> 3.170 </td> </tr> <tr> <td style="text-align:left;"> Ferrari Dino </td> <td style="text-align:right;"> 19.7 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 175 </td> <td style="text-align:right;"> 2.770 </td> </tr> <tr> <td style="text-align:left;"> Maserati Bora </td> <td style="text-align:right;"> 15.0 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 335 </td> <td style="text-align:right;"> 3.570 </td> </tr> <tr> <td style="text-align:left;"> Volvo 142E </td> <td style="text-align:right;"> 21.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 109 </td> <td style="text-align:right;"> 2.780 </td> </tr> </tbody> </table> --- class: middle ## Grouping rows ```r mtcars %>% select(mpg, cyl, hp, wt) %>% kable() %>% group_rows("Group 1", 1, 4) %>% group_rows("Group 2", 5, 9) %>% kable_styling(full_width = FALSE, bootstrap_options = "striped") ``` <table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> </th> <th style="text-align:right;"> mpg </th> <th style="text-align:right;"> cyl </th> <th style="text-align:right;"> hp </th> <th style="text-align:right;"> wt </th> </tr> </thead> <tbody> <tr grouplength="4"><td colspan="5" style="border-bottom: 1px solid;"><strong>Group 1</strong></td></tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Mazda RX4 </td> <td style="text-align:right;"> 21.0 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 2.620 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Mazda RX4 Wag </td> <td style="text-align:right;"> 21.0 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 2.875 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Datsun 710 </td> <td style="text-align:right;"> 22.8 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 93 </td> <td style="text-align:right;"> 2.320 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Hornet 4 Drive </td> <td style="text-align:right;"> 21.4 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 3.215 </td> </tr> <tr grouplength="5"><td colspan="5" style="border-bottom: 1px solid;"><strong>Group 2</strong></td></tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Hornet Sportabout </td> <td style="text-align:right;"> 18.7 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 175 </td> <td style="text-align:right;"> 3.440 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Valiant </td> <td style="text-align:right;"> 18.1 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 105 </td> <td style="text-align:right;"> 3.460 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Duster 360 </td> <td style="text-align:right;"> 14.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 245 </td> <td style="text-align:right;"> 3.570 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Merc 240D </td> <td style="text-align:right;"> 24.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 62 </td> <td style="text-align:right;"> 3.190 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Merc 230 </td> <td style="text-align:right;"> 22.8 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 95 </td> <td style="text-align:right;"> 3.150 </td> </tr> <tr> <td style="text-align:left;"> Merc 280 </td> <td style="text-align:right;"> 19.2 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 123 </td> <td style="text-align:right;"> 3.440 </td> </tr> <tr> <td style="text-align:left;"> Merc 280C </td> <td style="text-align:right;"> 17.8 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 123 </td> <td style="text-align:right;"> 3.440 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SE </td> <td style="text-align:right;"> 16.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 180 </td> <td style="text-align:right;"> 4.070 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SL </td> <td style="text-align:right;"> 17.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 180 </td> <td style="text-align:right;"> 3.730 </td> </tr> <tr> <td style="text-align:left;"> Merc 450SLC </td> <td style="text-align:right;"> 15.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 180 </td> <td style="text-align:right;"> 3.780 </td> </tr> <tr> <td style="text-align:left;"> Cadillac Fleetwood </td> <td style="text-align:right;"> 10.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 205 </td> <td style="text-align:right;"> 5.250 </td> </tr> <tr> <td style="text-align:left;"> Lincoln Continental </td> <td style="text-align:right;"> 10.4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 215 </td> <td style="text-align:right;"> 5.424 </td> </tr> <tr> <td style="text-align:left;"> Chrysler Imperial </td> <td style="text-align:right;"> 14.7 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 230 </td> <td style="text-align:right;"> 5.345 </td> </tr> <tr> <td style="text-align:left;"> Fiat 128 </td> <td style="text-align:right;"> 32.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 66 </td> <td style="text-align:right;"> 2.200 </td> </tr> <tr> <td style="text-align:left;"> Honda Civic </td> <td style="text-align:right;"> 30.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 52 </td> <td style="text-align:right;"> 1.615 </td> </tr> <tr> <td style="text-align:left;"> Toyota Corolla </td> <td style="text-align:right;"> 33.9 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 65 </td> <td style="text-align:right;"> 1.835 </td> </tr> <tr> <td style="text-align:left;"> Toyota Corona </td> <td style="text-align:right;"> 21.5 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 97 </td> <td style="text-align:right;"> 2.465 </td> </tr> <tr> <td style="text-align:left;"> Dodge Challenger </td> <td style="text-align:right;"> 15.5 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 150 </td> <td style="text-align:right;"> 3.520 </td> </tr> <tr> <td style="text-align:left;"> AMC Javelin </td> <td style="text-align:right;"> 15.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 150 </td> <td style="text-align:right;"> 3.435 </td> </tr> <tr> <td style="text-align:left;"> Camaro Z28 </td> <td style="text-align:right;"> 13.3 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 245 </td> <td style="text-align:right;"> 3.840 </td> </tr> <tr> <td style="text-align:left;"> Pontiac Firebird </td> <td style="text-align:right;"> 19.2 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 175 </td> <td style="text-align:right;"> 3.845 </td> </tr> <tr> <td style="text-align:left;"> Fiat X1-9 </td> <td style="text-align:right;"> 27.3 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 66 </td> <td style="text-align:right;"> 1.935 </td> </tr> <tr> <td style="text-align:left;"> Porsche 914-2 </td> <td style="text-align:right;"> 26.0 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 91 </td> <td style="text-align:right;"> 2.140 </td> </tr> <tr> <td style="text-align:left;"> Lotus Europa </td> <td style="text-align:right;"> 30.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 113 </td> <td style="text-align:right;"> 1.513 </td> </tr> <tr> <td style="text-align:left;"> Ford Pantera L </td> <td style="text-align:right;"> 15.8 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 264 </td> <td style="text-align:right;"> 3.170 </td> </tr> <tr> <td style="text-align:left;"> Ferrari Dino </td> <td style="text-align:right;"> 19.7 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 175 </td> <td style="text-align:right;"> 2.770 </td> </tr> <tr> <td style="text-align:left;"> Maserati Bora </td> <td style="text-align:right;"> 15.0 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 335 </td> <td style="text-align:right;"> 3.570 </td> </tr> <tr> <td style="text-align:left;"> Volvo 142E </td> <td style="text-align:right;"> 21.4 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 109 </td> <td style="text-align:right;"> 2.780 </td> </tr> </tbody> </table> --- class: middle ## Adding caption, footnote ```r mtcars %>% head() %>% select(mpg, cyl, hp, wt) %>% kable(caption="Car data from Motor Trend magazine.") %>% kable_styling(full_width = FALSE, bootstrap_options = "striped") %>% footnote(symbol = c("Footnote 1.", "Footnote 2")) ``` <table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;border-bottom: 0;"> <caption>Car data from Motor Trend magazine.</caption> <thead> <tr> <th style="text-align:left;"> </th> <th style="text-align:right;"> mpg </th> <th style="text-align:right;"> cyl </th> <th style="text-align:right;"> hp </th> <th style="text-align:right;"> wt </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Mazda RX4 </td> <td style="text-align:right;"> 21.0 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 2.620 </td> </tr> <tr> <td style="text-align:left;"> Mazda RX4 Wag </td> <td style="text-align:right;"> 21.0 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 2.875 </td> </tr> <tr> <td style="text-align:left;"> Datsun 710 </td> <td style="text-align:right;"> 22.8 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 93 </td> <td style="text-align:right;"> 2.320 </td> </tr> <tr> <td style="text-align:left;"> Hornet 4 Drive </td> <td style="text-align:right;"> 21.4 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 110 </td> <td style="text-align:right;"> 3.215 </td> </tr> <tr> <td style="text-align:left;"> Hornet Sportabout </td> <td style="text-align:right;"> 18.7 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 175 </td> <td style="text-align:right;"> 3.440 </td> </tr> <tr> <td style="text-align:left;"> Valiant </td> <td style="text-align:right;"> 18.1 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 105 </td> <td style="text-align:right;"> 3.460 </td> </tr> </tbody> <tfoot> <tr><td style="padding: 0; " colspan="100%"> <sup>*</sup> Footnote 1.</td></tr> <tr><td style="padding: 0; " colspan="100%"> <sup>†</sup> Footnote 2</td></tr> </tfoot> </table> --- class: middle # Summary * Several ways to customize the formatting of a table --- class: middle # Further reading * Course notes * `kableExtra` vignette --- class: middle, inverse ## Task Task 8 has some exercises for practing table presentation.