lundi 29 janvier 2018

Ifelse logical statement

I'm just starting to learn ifelse statements in functions. Here's a simplified example:

librar(knitr)

Tab <- iris

my_kable <- function(x, html = TRUE) {
  if(html) {  # any expression here in parentheses is evaluated before it's passed on to the if statement
    kable(x, kable_input = "html")
  } else {
    kable(x, kable_input = "latex")
  }
}

my_kable(Tab, html = FALSE)

The issue is in R Markdown, whether I put "html = FALSE" or "html = TRUE" I get the same result (an HTML table). I know I'm missing something very simple...

Aucun commentaire:

Enregistrer un commentaire