0

I'm working on an RMarkdown document and am running across a strange issue.

My document currently has three chunks, the first one is a table, the second a ggplot, and the third another table being produced using the knitr kable function.

The problem comes in the third chunk. For some reason when I knit to pdf the first column name is blocked by a black box. What makes it even stranger is that it only blocks it the first time the column name appears (the table stretches across two pages) I can't figure out why this is happening or how to remove the box.

My settings are as follows

yaml header:

title: ''
graphics: yes
header-includes:
- \usepackage{graphicx}
- \usepackage{fancyhdr}
- \fancyfoot[LE,RO]{SIG}
- \usepackage{xcolor}
- \usepackage{colortbl}
output: html_document
params:
  client: //filepath1.csv
  clientname: clientname
  clientsummary: //filepath2.csv
  refdate: 09/11/2015
tables: yes
geometry: margin=2.25cm

chunk code:

```{r kable, echo=FALSE,results='asis', warning=FALSE}
options(scipen=4,digits=2)
cftest <- read.csv(params$client)
cftest$TradeDate=(as.Date(cftest$TradeDate,"%m/%d/%Y"))
cftest$noticeDate=(as.Date(cftest$noticeDate,"%m/%d/%Y"))
cftest=na.omit(cftest[order(cftest$TradeDate),])
cftest$TradeDate=(as.character(cftest$TradeDate))
cftest$noticeDate=(as.character(cftest$noticeDate))          
library(knitr)
library(xtable)
library(gridExtra)
library(pander)
library(plyr)

cftest$OriginalAmount=format((cftest$OriginalAmount/1000000),big.mark = ",")
my.df=cftest[,c(1,3,6,9)]
kable(my.df,digits=2,row.names = FALSE,col.names=c("Notice Date","Amount ($M)","Trade Date","Manager"),caption="Possible Distributions")

If it helps I tried creating the table with xtable to see if that solved the problem but it does not. The black bar appears on the first column name as well.

I googled around for a while and it seems some people have a black bock appear on latex documents due to an overfull error but I don't see how that would be the case here,

I'm pretty perplexed by this, anyone have any thoughts?

p.s.

cftest is just a data frame with mixed data, numbers and text.

Rafael Velásquez
  • 337
  • 1
  • 3
  • 14
  • update: I figured out what the problem is but I'm not sure how to fix it. The issue only happens when a previous chunk is set to results='asis', if I remove that the black bar disappears. The issue is that I need results='asis' in order to render an xtable in the previous chunk. Why would this setting for a different chunk affect the behavior of my current chunk? – Rafael Velásquez Sep 18 '15 at 18:25
  • Would you please provide a directly reproducible example? – CL. Sep 20 '15 at 10:17
  • Hi, thanks for the help. I just figured out the problem. The issue was code I was using from this question(http://stackoverflow.com/questions/14632307/sweave-xtable-longtable-and-alternating-row-colors-problems-with-add-to-row) to create a zebra striped table, the code in the answer should be: from=1, to nrow(my.df)-1 instead of to nrow(my.df). The incorrect code adds an extra formatting line to the latex code which is what was causing the issue. – Rafael Velásquez Sep 22 '15 at 12:43

0 Answers0