Hey guys
When I am using cross-reference of figures in RMarkdown, warnings like this occur:
LaTeX Warning: Reference `fig:CARs-plot' on page 3 undefined on input line 235.
But I do following the instructions in RMarkdown Cookbook.
Besides, when I use cross-reference to tables, it works.
Bellow are two code chunks for a figure and a table respectively:
mascar$stkid = mascar$stkid+1
mascar = as.data.frame(cbind(mascar[,1], mascar[,4]))
mascarall = as.data.frame(cbind(mascarall[,1], mascarall[,4]))
colnames(mascar) = c("period", "cars")
colnames(mascarall) = c("period", "cars")
mascar3day = rbind(mascar, mascarall)
mascar1$stkid = mascar1$stkid+1
mascar1 = as.data.frame(cbind(mascar1[,1], mascar1[,4]))
mascarall2 = as.data.frame(cbind(mascarall2[,1], mascarall2[,4]))
colnames(mascar1) = c("period", "cars")
colnames(mascarall2) = c("period", "cars")
mascar10day = rbind(mascar1, mascarall2)
mascar3day$period = as.character(mascar3day$period)
mascar10day$period = as.character(mascar10day$period)
library(ggplot2)
p1 = ggplot(data=mascar3day, aes(x=cars, fill=period))+
geom_density(alpha=.3)
p2 = ggplot(data=mascar10day, aes(x=cars, fill=period))+
geom_density(alpha=.3)
library(gridExtra)
grid.arrange(p1, p2, nrow=2)
d = coef(summary(mod1))
d = d[1:10, 1:4]
rownames(d) = c("$C$", "$CFs$", "$Div$", "$PstGP$", "$GrsPftmg$", "$Qrt$", "$Cfp$", "$BE$", "$TrnovAcrc$", "$ROIC$")
e = knitr::kable(d, digits=4, caption = "Regression results relevant to the relation between CARs, cash flow and dividends.", format.args = list(big.mark = ",", scientific = FALSE), escape=FALSE)
e
And here are their chunk options:
{r CARs-plot, fig.cap='The distributions of CARs of M&As in two periods: recent five years and the entire company history.', echo=FALSE, warning=FALSE, message=FALSE}
{r regression, warning=FALSE, echo=FALSE, message=FALSE}