In R Markdown file, I use kable to create my table, I use argument "caption" to add title to my table, but once I add this caption, in the out put PDF file, the table I created will directly drop to the bottom of the pages, once I delete this caption, it went back to where it should be.
I tried in different laptop, it`s all the same.
---
title: "MA615_sep_13"
author: "KC"
date: "9/18/2019"
output:
pdf_document: default
df_print: paged
---
```{r setup, include=FALSE}
library(tidyverse)
library(knitr)
library(esquisse)
library(kableExtra)
library(magrittr)
library(tinytex)
opts_chunk$set(echo = TRUE)
```
Class assignment
Using the MPG dataset, which is available with the ggplot2 library, produce a document that includes the following elements: headers, text, tables, and plots.
Tables should include a comparison of city and highway mileage by the class of car and the best three car models for city and highway mileage for all the years in which data is available.
Plot the data displaying as much of the data as you can. Put continuous variables on the axes and include a locally smoothed regression line to show the relationship with mileage. Also make a box plot comparing city and highway MPG by class of car.
Table One:
data(mpg)
mpg_1=select(mpg,cty,hwy,class)
mpg_1 %<>% group_by(class)%>%
summarise(City=mean(cty),Highway=mean(hwy))%>%
arrange(class,City,Highway)
mpg_1 = mpg_1[order(mpg_1$City,decreasing = TRUE),]
# kable(mpg_1,format = 'latex',align = "c",
# col.names = c('Class','City MPG','Highway MPG'),
# booktabs = TRUE,
# digits = 2,
# caption = "Average City and Highway MPG by Car Class")0
knitr::kable(mpg_1,digits = 2,align = 'c',
col.names = c('Class','City MPG','Highway MPG'),
booktabs = TRUE,
caption = 'Average City and Highway MPG by Car Class')