I have a dataframe and I want to display that into a R markdown HTML file. I am able to generate a table using Kable function of Knitr, but I wanted to change look and feel, like highlighting the header. as some suggested on Stackoverflow to use xtable, I tried to do that. I took reference from Stackoverflow and try to design my outlike like this.
large <- function(x){
paste0('{\\Large{\\bfseries ', x, '}}')
}
italic <- function(x){
paste0('{\\emph{ ', x, '}}')
}
dat <- Final_Summary_table[1:3, 1:6]
print(xtable(dat),
sanitize.rownames.function = italic,
sanitize.colnames.function = large,
booktabs = TRUE,
floating = TRUE)
But instead of getting a beautiful table, what I am getting is something like we writee on a notepad.
% latex table generated in R 3.3.1 by xtable 1.8-2 package % Mon Nov 14 09:33:01 2016 \begin{table}[ht] \centering \begin{tabular}{rllrrrl} \toprule & {\Large{\bfseries ODS_Tables}} & {\Large{\bfseries AppDS_Tables}} & {\Large{\bfseries ODS_Total_Records}} & {\Large{\bfseries AppDS_Total_Records}} & {\Large{\bfseries Change_in_Count}} & {\Large{\bfseries Results}} \\ \midrule {\emph{ 1}} & HCC & tRefHCCCodes & 338.00 & 338.00 & 0.00 & PASS \\ {\emph{ 2}} & HCC\_COEFF & tRefHHCCOEFFs & 1166.00 & 794.00 & 372.00 & FAIL \\ {\emph{ 3}} & HCC\_HIERARCHY & tRefHHCHierarchies & 337.00 & 253.00 & 84.00 & FAIL \\ \bottomrule \end{tabular} \end{table}
any clue or help please.
I used follwing CSS formatting and it solved the issue.
<STYLE TYPE="text/css">
<!--
table {
width:100%;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
table tr:nth-child(even) {
background-color: #eee;
}
table tr:nth-child(odd) {
background-color:#fff;
}
table th {
background-color: black;
color: white;
}
--->
</STYLE>