0

I am trying to knit my r markdown file to a markdown, but when I use knitr::kable(df, format = "markdown") to display a data frame created with inspect(rules) from the arules package, I get the following:

"Warning in kable_markdown(x = structure(character(0), .Dim = c(0L,0L), .Dimnames = list(: The table should have a header (column names)"

This error does not occur within rstudio itself, and the data frame is output in a table as expected.

So far, I've been able to knit other data frames that weren't created with arules::inspect(rules) without a problem, and everything works.

I have tried manually setting col.names without success. I also tried setting col.names to FALSE and the error is the same.

rules = apriori(transactions, 
    parameter=list(support=.005, confidence=.1, minlen = 2))
sub_rules = arules::inspect(subset(rules, subset=lift > 1 & confidence > 0.2))
kable(head(sub_rules,15), format = "markdown", row.names = FALSE)
Sterling
  • 1
  • 1
  • It is hard to help without a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). If you can provide sample data and code that reproduces the error it is more likely somebody will be able to help. – joshpk Aug 12 '19 at 21:04

1 Answers1

0

I don't think inspect returns the subset of rules. You need code like:

sub_rules <- subset(rules, subset=lift > 1 & confidence > 0.2)
kable(head(sub_rules,15), format = "markdown", row.names = FALSE)
Michael Hahsler
  • 2,965
  • 1
  • 12
  • 16