Hi,
I have been using knitr::kable to produce a table from a matrix. The code:
m.OutTab <- as.matrix(m.OutTab)
m.OutTab <- gsub("NA%","",m.OutTab)
#Additional Suppressions
m.OutTab <- gsub("NaN%","",m.OutTab)
m.OutTab <- gsub("Inf%","",m.OutTab)
if(nchar(placename) != 0) {
names_spaced <- c("Year","Population","Growth Rate","Population","Growth Rate","Population","Growth Rate")
tblHead <- c(" " = 1, placename = 2, ctyname = 2, state = 2)
names(tblHead) <- c(" ", placename, ctyname,state)
} else {
names_spaced <- c("Year","Population","Growth Rate","Population","Growth Rate")
tblHead <- c(" " = 1, ctyname = 2, state = 2)
names(tblHead) <- c(" ", ctyname,state)
}
OutTab <- m.OutTab %>%
kable(format='html', table.attr='class="myTable"',
caption = "Population Growth Rate",
row.names=FALSE,
align='lrrrr',
col.names = names_spaced,
escape = FALSE) %>%
kable_styling(bootstrap_options = "condensed") %>%
column_spec(1, width = "0.4in") %>%
column_spec(2, width = "0.5in") %>%
column_spec(3, width = "0.5in") %>%
column_spec(4, width = "0.5in") %>%
column_spec(5, width = "0.5in") %>%
add_header_above(header=tblHead) %>%
add_footnote(captionSrc("SDO",""))
Out of nowhere I have been getting the following error in my development version of R
Warning: Error in rep: invalid 'times' argument
The error occurs at the creation of OutTab, the kable table.
I mean, really out of nowhere. This code has been running on out web server for the past 6 months without a problem.
Any ideas about why this is happening?
TIA